---
sourceDocument: Australia Build workflows
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/build-workflows

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia Build workflows

ft:clusterId :

    - crworkflow

bundleId :

    - crworkflow

workflow :

    - Creator


---

# Date and time

# Date and time transform functions {#ariaid-title1}

* Release version: Australia
* 
* Updated March 12, 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 6 minutes to read

Use date and time transform functions to recalculate or reformat data pills for
Date/Time values.
Date and time transform functions require a Date/Time or String input data pill. Some functions also support Duration data pills. Make sure to use the correct input [data pill type](https://servicenow-prod.fluidtopics.net/Ct3dsJ0IiWIcbamXVRVy2g "Actions and subflows use variables to store input and output data. The variable data type determines what kind of data it stores and its advanced configuration options.") when applying date and time transform functions. If a date and time transform function is applied to an improper data pill type, the data is not transformed
at runtime and the input value is returned instead. For more information on confirming your flow runtime values, see [Test a flow](https://servicenow-prod.fluidtopics.net/16GAKmUMqo2akmwgAuG1TA "Before activating a flow so other users can access it, test to make certain it works the way you expect.").  
Note:  
Runtime Date/Time values are not localized and appear in the UTC (Coordinated Universal Time) time zone. For more information, see [Time zones](https://www.servicenow.com/docs/access?context=r_TimeZones&version=australia&pubname=australia-platform-administration&ft:locale=en-US) and [time zone representation](https://support.servicenow.com/kb_view.do?sysparm_article=KB0594661).

## Add Time {#date-time-transform-functions__add-time}

Adds days, hours, minutes, or seconds to an input Date/Time, Date, Due Date, or Duration.  
{#date-time-transform-functions__table_elj_cdf_mkb__entry__3}

| Input data pill | Parameters | Output data pill |
|-|-|-|
| Date/Time, Date, Due Date, or Duration Note: If the input is a Date or Due Date, the transform creates a full Date/Time value using time values of hour 0, minute 0, and second 0. | Duration - Amount of time to add in days, hours, minutes, and seconds | Date/Time - Transformed Date/Time value after adding the specified Duration |
[ ]

{#date-time-transform-functions__table_elj_cdf_mkb}  
Figure 1. Example

* Input: `2019-09-12 11:00:00`
* Duration: `3 hours`
* Output: `2019-09-12
  14:00:00`
{#date-time-transform-functions__ul_g5q_d5y_2jb}

## Subtract Time {#date-time-transform-functions__subtract-time}

Subtracts days, hours, minutes, and/or seconds from the input Date/Time, Date, Due Date, or Duration.  
{#date-time-transform-functions__table_lvd_jff_mkb__entry__3}

| Input data pill | Parameters | Output data pill |
|-|-|-|
| Date/Time, Date, Due Date, or Duration Note: If the input is a Date or Due Date, the transform creates a full Date/Time value using time values of hour 0, minute 0, and second 0. | Duration - Enter an amount of time to subtract in days, hours, minutes, and seconds | Date/Time - Transformed Date/Time value after subtracting the specified Duration |
[ ]

{#date-time-transform-functions__table_lvd_jff_mkb}  
Figure 2. Example

* Input: `2019-09-12 11:00:00`
* Duration: `2 days, 1 hours, 5 minutes, 10 seconds`
* Output: `2019-09-10 09:54:50`
{#date-time-transform-functions__ul_mlj_4pz_2jb}

In this example, the flow retrieves a CMDB Configuration Item record from a remote
instance. The Subtract Time transform function then localizes the value of the
Created field by subtracting three hours from the input
Date/Time.  
Figure 3. Localize a field value's time zone

## String to Date {#date-time-transform-functions__string-to-date}

Converts the input String to a Date/Time.  
{#date-time-transform-functions__table_crn_5ff_mkb__entry__3}

| Input data pill | Parameters | Output data pill |
|-|-|-|
| String formatted as specified in the Input Date Format | * Input Date Format - Date/Time or date format of the input String * Custom Format - Valid Date/Time or date format represented as a String. Required only if Custom Format is selected as the Input Date Format. {#date-time-transform-functions__ul_e3c_grz_2jb} | Date/Time |
[ ]

{#date-time-transform-functions__table_crn_5ff_mkb}  
Note:  
* If the Date/Time value for the Custom Format input is incomplete, the transform creates a full Date/Time value using default dates and times. In such a case, the transform defaults to the current year, the current month, day 1 of a month, hour 0, minute 0, and second 0. For example, an input data pill value of Oct 2019 and a custom date format of MMM yyyy produces an output of `2019-10-01 00:00:00`.
* If you use an incorrect data pill type or invalid Custom Format, the flow cancels during runtime.
{#date-time-transform-functions__ul_nfr_dnj_lkb}  
Figure 4. Example

* Input: `'1995-11-20'`
* Input Date Format: `ISO Date (2004-06-28)`
* Output: `1995-11-20 00:00:00`
{#date-time-transform-functions__ul_g3c_grz_2jb}

## Date to String {#date-time-transform-functions__date-to-string}

Converts the input Date/Time, Date, or Due Date to a String. Select a Date Format for the input Date/Time. Alternatively, enter a Custom Format for the input Date/Time.  
{#date-time-transform-functions__table_pxn_5gf_mkb__entry__3}

| Input data pill | Parameters | Output data pill |
|-|-|-|
| Date/Time, Date, or Due Date | * Output Date Format - Date/Time or date format of the output String * Custom Format - Valid Date/Time or date format represented as a String. Required only if selecting Custom Format as the Date Format. {#date-time-transform-functions__ul_sv5_3sz_2jb} | String formatted as specified in the Output Date Format |
[ ]

{#date-time-transform-functions__table_pxn_5gf_mkb}  
Note:  
If you use an incorrect input data pill type or invalid Custom Format, the flow cancels during runtime.  
Figure 5. Example

* Input: `1969-12-31 14:23:57`
* Output Date Format: `Custom (enter below)`
* Custom Format: `'On' MMM dd, yyyy 'at' hh:mm a`
* Output: `'On Dec 31, 1969 at 2:23 PM'`

{#date-time-transform-functions__ul_uv5_3sz_2jb}

In this example, the flow retrieves a User \[sys_user\] record from a third-party
database. The Date to String transform function converts the format of the
Created field and then logs the date, time, and name that is
associated with the record.  
Figure 5. Concatenate a Date/Time value with a String value

## Custom date formats {#date-time-transform-functions__section_x2t_fzx_gjb}

You can specify a custom date format with a sequence of specific date and time pattern
strings. A pattern string consists of one or more uppercase and lowercase letters from A to
Z. Any text within quotation marks is ignored and is instead copied into the date
output.  
{#date-time-transform-functions__tbl_custom-date-formats__entry__4}

| String | Description | Output Format | Example |
|-|-|-|-|
| G | Era designator | Text | AD |
| y | Year | Year | 2019; 19 |
| Y | Week in year | Year | 2019; 19 |
| M | Month in year (within date) | Month | July; Jul; 07 |
| L | Month in year (standalone value) | Month | July; Jul; 07 |
| w | Week in year | Number | 52 |
| W | Week in month | Number | 1 |
| D | Day in year | Number | 365 |
| d | Day in month | Number | 2 |
| F | Day of week in month | Number | 3 |
| E | Day name in week | Text | Wednesday; Wed |
| u | Day number of week | Number | 3 |
| a | a.m. or p.m. | Text | p.m. |
| H | Hour in day from 0 through 23 | Number | 0 |
| k | Hour in day from 1 through 24 | Number | 24 |
| K | Hour in a.m. or p.m. from 0 through 11 | Number | 0 |
| h | Hour in a.m. or p.m. from 1 through 12 | Number | 12 |
| m | Minute in hour | Number | 59 |
| s | Second in minute | Number | 1 |
| S | Millisecond | Number | 500 |
| z | Time zone in default format | Time zone in default format | Pacific Standard Time; PST |
| Z | Time zone in RFC 822 format | Time zone in RFC 822 format | -0800 |
| X | Time zone in ISO 8601 format | Time zone in ISO 8601 format | -08; -0800; -08:00 |
[ ]

{#date-time-transform-functions__tbl_custom-date-formats}

## Day {#date-time-transform-functions__section_nsj_4s3_grb}

Retrieves the day component from the specified Date/Time.
{#date-time-transform-functions__table_cqp_vt3_grb__entry__2}

| Input data pill | Output data pill |
|-|-|
| Date/Time | Integer - Day from the specified date. |
[ ]

{#date-time-transform-functions__table_cqp_vt3_grb}  
Figure 7. Example

* Input: `2021-11-20 13:06:12`
* Input Date Format: `ISO Date
  (2004-06-28)`
* Output: `20`
{#date-time-transform-functions__ul_wzn_dx3_grb}

## Hour {#date-time-transform-functions__section_zkc_by3_grb}

Retrieves the hour component from the specified Date/Time.
{#date-time-transform-functions__table_tw2_2y3_grb__entry__2}

| Input data pill | Output data pill |
|-|-|
| Date/Time | Integer - Hour from the specified date. |
[ ]

{#date-time-transform-functions__table_tw2_2y3_grb}  
Figure 8. Example

* Input: `2021-11-20 13:06:12`
* Input Date Format: `ISO Date
  (2004-06-28)`
* Output:`13`
{#date-time-transform-functions__ul_mb1_ly3_grb}

## Minute {#date-time-transform-functions__section_ybw_yy3_grb}

Retrieves the minute component from the specified Date/Time.
{#date-time-transform-functions__table_bqh_kz3_grb__entry__2}

| Input data pill | Output data pill |
|-|-|
| Date/Time | Integer - Minute component from the specified date. |
[ ]

{#date-time-transform-functions__table_bqh_kz3_grb}  
Figure 9. Example

* Input: `2021-11-20 13:06:12`
* Input Date Format: `ISO Date
  (2004-06-28)`
* Output: `06`
{#date-time-transform-functions__ul_rqq_dz3_grb}

## Second {#date-time-transform-functions__section_bnn_pz3_grb}

Retrieves the second component from the specified Date/Time.
{#date-time-transform-functions__table_zbl_sz3_grb__entry__2}

| Input data pill | Output data pill |
|-|-|
| Date/Time | Integer - Second component from the specified date. |
[ ]

{#date-time-transform-functions__table_zbl_sz3_grb}  
Figure 10. Example

* Input: `2021-11-20 13:06:12`
* Input Date Format: `ISO Date
  (2004-06-28)`
* Output: `12`
{#date-time-transform-functions__ul_rgl_wbj_grb}

## Month {#date-time-transform-functions__section_swr_jcj_grb}

Retrieves the month component from the specified Date/Time.
{#date-time-transform-functions__table_lh2_cdj_grb__entry__2}

| Input data pill | Output data pill |
|-|-|
| Date/Time | Integer - Month component from the specified date. |
[ ]

{#date-time-transform-functions__table_lh2_cdj_grb}  
Figure 11. Example

* Input: `2021-11-20 13:06:12`
* Input Date Format: `ISO Date
  (2004-06-28)`
* Output: `11`
{#date-time-transform-functions__ul_csm_hdj_grb}

## Week {#date-time-transform-functions__section_ezm_ldj_grb}

Evaluates the week number for the specified Date/Time.
{#date-time-transform-functions__table_p3g_xdj_grb__entry__2}

| Input data pill | Output data pill |
|-|-|
| Date/Time | Integer - Week number for the specified date. |
[ ]

{#date-time-transform-functions__table_p3g_xdj_grb} Figure 12. Example

* Input: `2021-04-07 12:01:12`
* Input Date Format: `ISO Date
  (2004-06-28)`
* Output: `15`
{#date-time-transform-functions__ul_q4n_b2j_grb}

## Year {#date-time-transform-functions__section_ryv_32j_grb}

Retrieves the year component from the specified Date/Time.{#date-time-transform-functions__table_uhb_l2j_grb__entry__2}

| Input data pill | Output data pill |
|-|-|
| Date/Time | Integer - Year component from the specified date. |
[ ]

{#date-time-transform-functions__table_uhb_l2j_grb}
Figure 13. Example

* Input: `2021-04-07 12:01:12`
* Input Date Format: `ISO Date
  (2004-06-28)`
* Output: `2021`
{#date-time-transform-functions__ul_i2t_42j_grb}

## Date Difference {#date-time-transform-functions__section_ahv_hfj_grb}

Evaluates the time duration difference between the specified input date and the parameter
date and then adds the difference time duration to the Epoch time (1970-01-01 00:00:00).
{#date-time-transform-functions__table_o3p_kfj_grb__entry__3}

| Input data pill | Parameters | Output data pill |
|-|-|-|
| Date/Time, Date, or Due Date | Date/Time, Date, or Due Date | Duration - Time duration difference added to the Epoch time (1970-01-01 00:00:00). |
[ ]

{#date-time-transform-functions__table_o3p_kfj_grb} Figure 14. Example

* Input: `2021-05-02 09:10:12`
* Input Date Format: `ISO Date
  (2004-06-28)`
* Parameters: `2021-04-07 06:02:23`
* Output: `1970-01-26 03:07:49`
{#date-time-transform-functions__ul_ppk_dgj_grb}

## End of Month {#date-time-transform-functions__section_ps1_kgj_grb}

Evaluates the last day of the month after adding the specified number of the months to the
specified date.
{#date-time-transform-functions__table_rvl_rgj_grb__entry__3}

| Input data pill | Parameters | Output data pill |
|-|-|-|
| Date | Number of Months - Months to add to the specified date. | Integer - Last day of the month after adding the number of months to the specified input date. |
[ ]

{#date-time-transform-functions__table_rvl_rgj_grb} Figure 15. Example

* Input: `2021-11-20`
* Input Date Format: `ISO Date
  (2004-06-28)`
* Number of Months: `3`
* Output: `2022-02-28`
{#date-time-transform-functions__ul_i4t_3hj_grb}

