|
Date, date/time and time functions
The locale also influences the output of the different Date functions; see Locale.
To format a date from a
date field in the record set, you can enter a formatting pattern directly in the Text Script Wizard; see Using the Text Script Wizard, Formatting variable data and Date and time patterns).date(value, pattern)Formats a date object using a custom pattern. value A Date object. A Date can contain a date and time. pattern String. The custom pattern may consist of pattern letters, separating symbols and quoted text, for example: "MMMM dd, yyyy"; see Date and time patterns. Note that the repetition of pattern letters determines the exact presentation. dateLong(value)Formats a date as long string representation, for example April 1, 2016. value A Date object. A Date can contain a date and time. dateMedium(value)Formats a date as medium string representation, for example 01/04/16. value A Date object. A Date can contain a date and time. dateShort(value)Formats a date as short string representation, for example 1-Apr-2016. value A Date object. A Date can contain a date and time. dateTime(value, pattern)Formats a date and time object using a custom pattern. value A Date object. A Date can contain a date and time. pattern String. The custom pattern may consist of pattern letters, separating symbols and quoted text, for example: "yyyy.MM.dd G 'at' HH:mm:ss z"; see Date and time patterns. Note that the repetition of pattern letters determines the exact presentation. dateTimeLong(value)Formats a date and time as long string representation, for example April 1, 2016 12:00:00 EDT AM. value A Date object. A Date can contain a date and time. dateTimeMedium(value)Formats a date and time as medium string representation, for example 1-Apr-2016 12:00:00 AM. value A Date object. A Date can contain a date and time. dateTimeShort(value)Formats a date and time as short string representation, for example 01/04/16 12:00 AM. value A Date object. A Date can contain a date and time. time(value, pattern)Formats a time using a custom pattern. value A Date object. A Date can contain a date and time. pattern String. The custom pattern may consist of pattern letters, separating symbols and quoted text, for example: "'at' HH:mm:ss z"; see Date and time patterns. Note that the repetition of pattern letters determines the exact presentation. timeLong(value)Formats a time as long string representation, for example 12:00:00 EDT AM. value A Date object. A Date can contain a date and time. timeMedium(value)Formats a time as medium string representation, for example 12:00:00 AM. value A Date object. A Date can contain a date and time. timeShort(value)Formats a time as short string representation, for example 12:00 AM. value A Date object. A Date can contain a date and time. ExamplesThe following script passes the value of a field in the record set to the date() function. This will only work if the type of the field has been set to Date in the Data Mapping Configuration and if the field contains a valid date.
The custom pattern that the script provides, outputs the month and day in two digits each and the year in four digits: 05/21/2016. For more examples of formatting patterns, see Date and time patterns. Creating a Date object from a string
The following sample script demonstrates this solution. It splits a string into parts and then creates a new Date object with the parts in the correct order. To construct a Date, the parts of the date must be put in the following order: year, month, day, and optionally hours, minutes, seconds, milliseconds (see http://www.w3schools.com/js/js_dates.asp and https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date.) When the time is omitted, it defaults to 12:00:00 AM.
JavaScript counts months from 0 to 11. January is 0. December is 11.
Another way to put a string in a Date is to use the The
|
|