Custom datetime formats

Custom datetime formats allow you to define specific patterns for converting datetime values into string representations. Use predefined conventions to specify a custom datetime format. These formats enable you to display dates and times in a way that suits your specific needs.

Use predefined conventions to specify a custom datetime format. Here are some examples of custom datetime formats:
Note: All predefined conventions that are used to specify a custom datetime format are case-sensitive.

Format 'y' and 'Y'

Specify a year as 'yy' or 'yyyy' and specify the year of the week as 'YY' respectively.
Note: The ‘yy’ and ‘YY’ provide the same result, however the result differs if you use a datetime format that includes the last week or the first week of a calendar year.

For example, when you use a datetime format as 12/26/22 (2022/12/26), then perform actions to delete the files from the previous year, the datetime format ‘yy’ provides correct result (12/26/21) and the files from the year 2021 are deleted. If you use the datetime format ‘YY’ (indicating the year of the week in which the specific day appears), then files from the year 2022 will be deleted because the day 12/26/21 falls during the last week of 2021 and also during the first week of 2022.

Sample calendar

We recommend that you use the datetime format 'yy' when you want to consider the calendar year only and not a specific week of that calendar year.

Format 'M'

Specify a month as 'M', 'MM', 'MMM' (abbreviated name of the month, for example, Jan, Feb), or 'MMMM' (full name of the month, for example, January, February).
Note: The 'MMM' and 'MMMM' datetime formats work depending on the operating system on which the Bot Agent runs and your location setting.

Format 'd'

Specify a day as 'd' or 'dd'.

Format 'D'

Specify a day in a year as 'D' or 'DD'.

Format 'E'

Specify day of the week as 'EEE' (Sun-Sat) or 'EEEE' (Sunday-Saturday).
Note: The 'EEE' and 'EEEE' datetime formats work depending on the operating system on which the Bot Agent runs and your location setting.

Format 'F' or 'FF'

Specify day of the week in a month with or without leading zero. For example, yyyy-ww-F or yyyy-ww-0F.
Note: To specify the day of the week in a month, you can also specify the fixed format as ISO_WEEK_DATE ('2012-W48-6')

Format 'h' or 'H'

Specify an hour as 'hh' or 'HH'.
Note: HH is a 24-hour time format, and hh is a 12-hour time format with AM or PM. When you use the hh format, add a at the end of the datetime format. For example, if the system locale language is English, the input will be 2018-12-25 10:50:55.999 AM and the format will be yyyy-MM-dd hh:mm:ss.SSS a where a indicates AM or PM. However, on computers that use operating systems in languages other than English, use AM or PM marker accordingly. For example, on a Japanese language operating system, the input must have AM or PM marker in Japanese, such as 2018-12-25 10:50:55.999 午前, where 午前 means AM in Japanese, and the format must be yyyy-MM-dd hh:mm:ss.SSS a.

Format 'a'

Specify an AM/PM marker for the 12-hour time format.

Format 'm'

Specify a minute in an hour as 'mm'.

Format 's'

Specify a second in a minute as 'ss'.

Format 'S'

Specify a millisecond as 'SSS'.

Format 'z'

Specify a timezone, such as 'Pacific Standard Time' and 'Indian Standard Time'.

Format 'Z'

Specify an offset time for a timezone, such as '+0550' for 'Indian Standard Time'.

Important: On computers where the display language is set to Simplified Chinese or Traditional Chinese, when you use the dd-MMM-yyyy custom datetime format to convert a datetime value to a string value, the output might show incorrectly.

Examples

You can use the preceding convention to specify the custom format that you want to use for converting a datetime value. Some examples that use the preceding convention are as follows:
Note: The format h.mm a is currently not supported.
Format Sample output
yyyy-MM-dd 2018-09-08
yyyy-M-d 2018-9-8
dd-MM-yyyy 08-09-2018
yyyy-MM-dd HH:mm:ss 2018-09-08 23:50:55
hh:mm:ss.SSS a 10:15:35.889 AM / 10:15:35.889 PM
yyyy-MM-dd HH:mm:ss.SSS 2018-09-08 23:50:55.999
yyyy-MM-dd HH:mm:ss.SSS Z 2018-09-08 23:50:55.999 +0530
D:dd-MM-yyyy 130:08-09-2018
D 'days', yyyy 365 days, 2019