Changes

Jump to: navigation, search

Manipulating Dates

879 bytes added, 14:13, 4 April 2014
no edit summary
{{JavaScript Syntax}}The following [[JavaScript]] functions are built-in to SmartSimple to assist when working with manipulation and performing calculations using dates:
==ConvertDateStr==
==NotesssConvertDate==Takes a date in any date format and converts it to any other date format. '''Syntax:'''<br>:<font size="3">'''ssConvertDate(''date'','fromdateformat','todateformat')'''</font> '''Where:'''* When populating a ''date field that '' is displayed on the page it must be added in date you wish to change to the users preferred date display format.* ''fromdateformat'' is the format of the current user, as date you are providing* ''todateformat'' is the format you want the system will automatically change it resulting date to use. '''Example:''' var newDate=ssConvertDate(sdate,'yyyy-mm-dd when the page is saved.','dd/mm/yyyy');or var newDate=ssConvertDate(sdate,'mm/dd/yyyy','dd-mm-yyyy');
::* 'd' (days)
::* 'm' (months)
::* 'yyyyy' (years)
* ''interval'' is the number of days/months/years to be added.
'''Example:'''
var newDate=ConvertDatedateadd(sdate,'m',duration);
 ===Example===
The following example adds a specified number of months (saved in cf_123456) to the startdate, and saves it as the enddate.
}
var edate=dateadd(sdate,'m',duration);
frm.enddate.value=ConvertDatessConvertDate(edate,"@dateformat@");
</pre>
 
 
 
==Notes==
* When using [[JavaScript]] to populate a date it must be added to the field in the preferred date format of the current user, as the system will automatically convert it to yyyy-mm-dd when the page is saved.
 
* To change the display format of dates displayed on the page see [[sscalculation]]
* [[isHoliday]]
* [[Custom Defined Holidays]]
* [[Sscalculation]]
* [[Template_/_Type_Formula#Counting_and_Adding_Business_Days|Using Template Formulas to Count and Add Business Days]]
 
[[Category:JavaScript]]
[[Category:validate.js]][[Category:Date Formats]]
8,849
edits

Navigation menu