DateTime conversion |
By default, time values in tables are assumed to be UTC (Coordinated Universal Time), rather than a local time zone. This is a culture-specific date string followed by the time, expressed using a 12-hour clock.
This topic contains the following sections:
You always have the option to convert a Timestamp value into a preferred string representation, using Windows Date/Time format string specifiers. Whether you must format your time values depends on whether your local data is structured for non-UTC time zones:
ReportStart(Timestamp)
PurchaseTime(yyyy-MM-dd HH:mm, PST)
Examples:
ReportStart(Timestamp) = "Report start time" # uses default UTC without formatting --------------------------------------------------------------------------------------------------- PurchaseTime(yyyy-MM-dd HH:mm) = Input.SwipeTime # converts and formats UTC to preferred format --------------------------------------------------------------------------------------------------- RunningTime(hh:mm) = Input.RunTime # converts and formats TimeInterval to a string --------------------------------------------------------------------------------------------------- PurchaseTime(yyyy-MM-dd HH:mm, PST) = Input.SwipeTime # converts and formats from UTC to time zone
To explicitly specify the mapping between a Timestamp or TimeInterval and its string representation, use a Windows Date/Time format string. This can be a simple Format specifier or a custom format string built up from a set of Date/Time format characters and string literals. You may not use a comma as part of a format string.
The following table describes the standard format specifiers for formatting the DateTime values:
Specifier | Name | Example |
---|---|---|
d | Short date | "8/9/2009" |
D | Long date | "Sunday, August 09, 2009" |
f | Full date/time - short time | "Sunday, August 09, 2009 2:44 PM" |
F | Full date/time - long time | "Sunday, August 09, 2009 2:44:01 PM" |
g | General date/time - short | "8/9/2009 2:44 PM" |
G | General date/time - long | "8/9/2009 2:44:01 PM" |
t | Short time | "2:44 PM" |
T | Long time | "2:44:01 PM" |
The following table describes custom date/time format characters:
Specifier | Description |
---|---|
d | The current day of the month as a number between 1 and 31, inclusive. If the day is a single digit only (1-9), then it is displayed as a single digit. |
dd | The current day of the month as a number between 1 and 31, inclusive. If the day is a single digit only (1-9), it is formatted with a preceding 0 (01-09). |
ddd | The abbreviated name of the day. |
dddd | The full name of the day. |
f or F | The most significant digit of the seconds fraction. |
h | The hour in the range 1-12. If the hour is a single digit (1-9), it is displayed as a single digit. |
hh | The hour in the range 1-12. If the hour is a single digit (1-9), it is formatted with a preceding 0 (01-09). |
H | The hour in the range 0-23. If the hour is a single digit (1-9), it is displayed as a single digit. |
HH | The hour in the range 0-23. If the hour is a single digit (1-9), it is formatted with a preceding 0 (01-09). |
m | The minute in the range 0-59. If the minute is a single digit (0-9), it is displayed as a single digit. |
mm | The minute in the range 0-59. If the minute is a single digit (0-9), it is formatted with a preceding 0 (01-09). |
M | The month, as a number between 1 and 12, inclusive. If the month is a single digit (1-9), it is displayed as a single digit. |
MM | The month, as a number between 1 and 12, inclusive. If the month is a single digit (1-9), it is formatted with a preceding 0 (01-09). |
MMM | The abbreviated name of the month. |
MMMM | The full name of the month. |
s | The seconds in the range 0-59. If the second is a single digit (0-9), it is displayed as a single digit only. |
ss | The seconds in the range 0-59. If the second is a single digit (0-9), it is formatted with a preceding 0 (01-09). |
t | The first character of the A.M./P.M. designator. |
tt | The A.M./P.M. designator. |
y | The year as a one- or two-digit number. The first two digits of the year are omitted. If the year is a single digit (1-9), it is displayed as a single digit. |
yy | The year as a one- or two-digit number. The first two digits of the year are omitted. If the year is a single digit (1-9), it is formatted with a preceding 0 (01-09). |
yyyy | The year, including the century. If the year is less than four digits in length, then preceding zeros are appended as necessary to make the displayed year four digits long. |
z | The time zone offset for the system's current time zone in whole hours only. The offset is always displayed with a leading sign (zero is displayed as "+0"), indicating hours ahead of Greenwich mean time (+) or hours behind Greenwich mean time (-). The range of values is –12 to +13. If the offset is a single digit (0-9), it is displayed as a single digit with the appropriate leading sign. |
zz | The time zone offset for the system's current time zone in whole hours only. The offset is always displayed with a leading or trailing sign (zero is displayed as "+00"), indicating hours ahead of Greenwich mean time (+) or hours behind Greenwich mean time (-). The range of values is –12 to +13. If the offset is a single digit (0-9), it is formatted with a preceding 0 (01-09) with the appropriate leading sign. |
zzz | The time zone offset for the system's current time zone in hours and minutes. The offset is always displayed with a leading or trailing sign (zero is displayed as "+00:00"), indicating hours ahead of Greenwich mean time (+) or hours behind Greenwich mean time (-). The range of values is –12:00 to +13:00. If the offset is a single digit (0-9), it is formatted with a preceding 0 (01-09) with the appropriate leading sign. |
: | Time separator. |
/ | Date separator. |
The time zone string can be any of the values in the following table:
Tip |
---|
Time zone values include the calculation for the offset from UTC standard time as well as any offsets required for daylight savings time. For details, see the TimeZone table documentation. |
Specifier | Time Zone | Example location (Continent/City or Country) |
---|---|---|
ACN | - | Australia/Adelaide (no Daylight Savings) |
ACS | Australian Central Standard Time | Australia/Adelaide |
AEN | - | Australia/Sydney (no Daylight Savings) |
AES | Australian Eastern Standard Time | Australia/Sydney |
AFT | Afghanistan Time | Asia/Afghanistan |
AKT | Alaska Standard Time | America/Anchorage |
AMS | - | Europe/Armenia |
ARN | Argentina | South America/Buenos Aires |
ART | Argentina Time | South America/Argentina |
AST | Arizona | America/Phoenix (no Daylight Savings) |
ATT | Atlantic Standard Time | Altantic |
AWS | Australian Western Standard Time | Australia/Perth |
AZT | Azerbaijan Time | Europe/Azerbaijan |
BDT | Bangladesh Daylight Time (Bangladesh Daylight saving time keeps UTC+06 offset) | Asia/Bangladesh |
BOT | Bolivia Time | South America/Bolivia |
BRN | Brazil | America/Fortaleza (no Daylight Savings) |
BRT | Brazil | America/Sao Paulo |
BTA | - | Asia/Brunei |
BTT | Bhutan Time | Asia/Bhutan |
CAT | Central Africa Time | Africa/Maputo |
CBT | - | Central America/Cuba |
CCT | Cocos Islands Time | Asia/Cocos Island |
CET | Central European Time | Europe/Vienna |
CLT | Chile | America/Santiago |
CNT | China Time | Asia/Shanghai |
COL | Colombia | America/Bogota |
COT | Colombia Time | South America/Colombia |
CST | Central Standard Time | America/Chicago |
CVT | Cape Verde Time | Africa/Cape Verde |
CXT | Christmas Island Time | Asia/Christmas Island |
EAT | East Africa Time | Africa/Khartoum |
ECA | - | America/Caribbean |
ECT | Ecuador Time | South America/Ecuador |
EET | Eastern European Time | Europe/Athens |
EGS | - | North America/Greenland |
EIT | Eastern Indonesian Time | Asia/Indonesia |
EST | Eastern Standard Time | America/New York |
FJT | Fiji Time | Oceania/Fiji |
FKS | Falkland Islands Standard Time | South America/Falkland Islands |
GIL | Gilbert Island Time | Pacific/Kiribati |
GSS | - | Europe/Georgia |
GST | Gulf Standard Time | Asia/Dubai |
GYT | Guyana Time | South America/Guyana |
HKT | Hong Kong Time | Asia/Hong Kong |
HMT | Heard and McDonald Islands Time | Antarctica/Heard and McDonald Islands |
HST | Hawaii-Aleutian Standard Time | Pacific/Honolulu |
IOT | Indian Ocean Time | Asia/India |
IRD | Iran Daylight Time | Asia/Iran |
JST | Japan Standard Time | Asia/Japan |
MEX | Mexico | America/Mexico City |
MHT | Marshall Islands | Oceania/Marshall Islands |
MIT | - | PNG/Manus |
MST | Mountain Standard Time | America/Denver |
MUT | Mauritius Time | Africa/Mauritius |
MVT | Maldives Time | Asia/Maldives |
MYT | Malaysia Time | Asia/Malaysia |
NCT | New Caledonia Time | Oceania/New Caledonia |
NMT | Namibia Time | Africa/Windhoek |
NPT | Nepal Time | Asia/Nepal |
NRT | - | Pacific/Nauru |
NST | Newfoundland Standard Time | America/St. Johns |
NUT | Niue Time | Oceania/Niue |
NZT | New Zealand Standard Time | Pacific/Auckland |
PER | - | South America/Peru |
PET | Peru Time | America/Lima |
PGT | Papua New Guinea Time | Oceania/Papua New Guinea |
PHT | Philippine Time | Asia |
PKT | Pakistan Standard Time | Asia/Pakistan |
PNG | - | Africa/Guinea |
PRT | Puerto Rico | America/Puerto Rico (no Daylight Savings) |
PST | Pacific Standard Time | America/Los Angeles |
PYT | Paraguay Time (South America) | South America/Paraguay |
SAM | - | Oceania/Samoa |
SAS | South African Standard Time | Africa/South Africa |
SAT | South African Time | Africa/Johannesburg |
SBT | Solomon Islands Time | Oceania/Solomon Islands |
SCT | Seychelles Time | Africa/Seychelles |
SGT | Singapore Time | Antarctica/South Sandwich Islands |
SIT | - | Asia/Singapore |
SKT | Saskatchewan | America/Regina (no Daylight Savings) |
SLS | Sri Lanka Standard Time | Asia/Sri Lanka |
SRT | Suriname Time | South America/Suriname |
SST | Saudi Arabia Standard Time | Asia/Riyadh |
THA | Thailand Standard Time | Asia/ |
TJT | Tajikistan Time | Asia/Tajikistan |
TKT | Tokelau Time | Oceania/TokelauThailand |
TMT | Turkmenistan Time | Asia/Turkmenistan |
TOT | Tonga Time | Oceania/Tonga |
TVT | Tuvalu Time | Oceania/Tuvalu |
UTC | Coordinated Universal Time | Europe/Greenwich |
UYS | Uruguay Summer Time | South America/Uruguay |
UZT | Uzbekistan Time | Asia/Uzbekistan |
VET | Venezuela | America/Caracas |
VUT | Vanuatu Time | Oceania/Vanuatu |
WAT | West Africa Time | Africa/Lagos |
WET | Western European Time | Europe/London |