Returns the current date in one of several different formats. Optionally it will convert a supplied date from one supported format to another. It will also adjust the current or supplied date by a specified number of days.
Date returns the current date or a supplied date in one of several different formats. Optionally it can adjust the date by a specified number of days.
date([option_out [,option_in [,date [,adjust]]]])
- One of International, European, American(USA), Sorted(Standard), Base, Days, Timestamp or Weekday.
- Note that only the first character is used. Any remaining characters are ignored. This will apply even if the word is spelled incorrectly.
- One of International, European, American(USA), Sorted(Standard), Base, Day, Timestamp or Weekday.
- If this option is specified, it defines the format of the date in the following parameter.
- Date to be used as source in the format specified by option_in. If this date is omitted, option_in is ignored and the current date is used.
- An adjustment to be applied to the input date. This is a whole number of days to be added or subtracted. A positive value gives a date in the future.
A string containing the current, converted and/or adjusted date depending on the options specified.
Where an output option only is specified the current date is converted to the that format.
If there is no option or the option is invalid, the current date is returned in the International format: yyyy-mm-dd.
If an input date is specified, that date is used instead of the current date.
If an adjustment is specified this number of days is added or subtracted to the input date. A positive value gives a date in the future.
- International/ISO date in the format: yyyy-mm-dd (yyyy, mm, and dd all have leading zeros).
- European date in the format: dd/mm/yyyy (dd, mm, and yyyy all have leading zeros).
- USA date in the format: mm/dd/yyyy (mm, dd, and yyyy all have leading zeros).
- Sortable date in the format: yyyymmdd (suitable for sorting - yyyy, mm, and dd all have leading zeros).
- The number of complete days (that is, not including the current day) since and including the base date, 1 January 0001, in the format: dddddd (no leading zeros or blanks). The expression date('B') mod 7 returns a number in the range 0–6 that corresponds to the current day of the week, where 0 is Monday and 6 is Sunday. This function can therefore be used to determine the day of the week independent of the national language in which you are working. 1)
- The number of days, including the current day, so far in the current year in the format: ddd (no leading zeros or blanks).
- Unix timestamp as a decimal number. This is the number of seconds since 01/01/1970 00:00:00 UTC until 00:00:00 today.
- The number of the day of the week starting with Monday. Monday is 1 and Sunday is 7.
The first call to date or time in one clause causes a time stamp to be made that is then used for any further calls to date or time in that clause. This means that multiple calls to either function in a single expression or clause will be consistent with each other.
Here are some examples for the date 31 August 2008:
date() -> '2008-08-31' date('I') -> '2008-08-31' date('E') -> '31/08/2008' date('A') -> '08/31/2008' date('S') -> '20080831' date('T') -> '1220140800' /* Seconds since 01/01/1970 00:00:00 UTC */ date('B') -> '733284' /* Whole days since 01/01/0001 00:00:00 */ date('D') -> '244' date('W') -> '7' /* Sunday */
Convert dates from ISO with adjustment:
date('B','I','2008-08-31',-3) -> '733281' date('D','I','2008-08-31',-2) -> '242' date('E','I','2008-08-31',-1) -> '30/08/2008' date('A','I','2008-08-31',+1) -> '09/01/2008' date('S','I','2008-08-31',+2) -> '20080902' date('T','I','2008-08-31',+3) -> '1220400000'
|The 's' option is to be dropped and used instead for the date serial format.|
|Currently the date function returns the ISO format date only, otherwise there is limited support revolving around VB date serials.|
| To be implemented
|Currently there is limited support for date handling using the following Xst library functions.|