Date
The Date function returns the equivalent date of the input string.
Prototype
Date(String; Format; DateType)
Arguments
String String By value
A literal, an expression or a variable (Studio only) containing a valid date.
Format String By value
A string that defines the format of the String parameter (string representation of a date).
See Format Key.
DateType String By value
A literal, an expression or a variable (Studio only) containing a valid date type.
See DateType.
Returns
Date
The Date in UTC format
Exception
Undefined
Undefined is returned if:
- String parameter is Undefined or is not a String.
- Format parameter is not valid.
- Format parameter is not defined and String parameter is not a valid Date.
Format Key
| Format Key | Description |
|---|---|
| d | The day of the month from 1 through 31 |
| dd | The day of the month from 01 through 31 |
| M | The month from 1 through 12 |
| MM | The month from 01 through 12 |
| yy | The year in two digit format |
| yyyy | The year in four digit format |
| H | The hour from 0 through 23 |
| HH | The hour from 00 through 23 |
| m | The minute from 0 through 59 |
| mm | The minute from 00 through 59 |
| s | The second from 0 through 59 |
| ss | The second from 00 through 59 |
Examples
dd-MM-yyyy HH:mm:ss
MM/dd/yyyy HH:mm:ss
Using predefined formats (no case sensitive) without separators
mmyyyy
mmyyyyhhmmss
yyyymm
yyyymmhhmmss
ddmmyyyy
ddmmyyyyhhmmss
mmddyyyy
mmddyyyyhhmmss
yyyymmdd
yyyymmddhhmmss
yyyyddmm
yyyyddmmhhmmss
Empty format string
If the format parameter is empty the following standard formats will be used to parse the String parameter.
myyyy
mmyyyy
mddyyyy
mmddyyyy
DateType
Supported Data Types (not case sensitive):
| DateType | Description |
|---|---|
| SFhub | Date and time will be converted using the time zone of the SFHub application server. |
| SFServer | Date and time will be converted using the time zone of the Sigmafine Server. |
| User | Date and time will be converted using the time zone of the user evaluating the function. |
| Utc | Date and time are assumed in UTC format. |
| Empty or missed | Date and time will be converted using the time zone of the SFHub application server. |
If omitted, the date is converted to the SFHub time zone (default timezone).
Example
Date ('052020' ; '')
The standard format mmyyyy is automatically applied. It will return 05/01/2020 0:0:0 UTC.
Date ('52020' ; '')
The standard format myyyy is automatically applied. It will return 05/01/2020 0:0:0 UTC.
Notice that the date is enclosed in single quotes; this is because the first character is a zero.
Date('20200502';'yyyyMMdd')
Will return 05/01/2020 22:00:00 UTC.
Date('20200502';'yyyyMMdd' ; 'User')
The date is assumed as local to the user's time zone and then converted into UTC. In our case the time zone of the user is GMT +1
Notice that if the user's time zone is the same of the SFHub application server and of the Sigmafine server the resulting date will be the same also using different date types
Date('20200502';'yyyyMMdd' ; 'SFhub')
Date('20200502';'yyyyMMdd' ; 'SFServer')