Date and time functions - Cloud

Talend Data Shaping Language Reference Guide

Version
Cloud
Language
English (United States)
Product
Talend Cloud
Module
Data Shaping Language
Content
Design and Development

The following functions can be used to perform operations on dates, times and datetimes.

Function Description Arguments Example
addToDateTime Adds an amount of time to a datetime.
  1. Unit to add as a string:
    • Year, Years, Y or u for years
    • Month, Months, M or L for months
    • Week, Weeks or W for weeks
    • Day, Days or d for days
    • Hour, Hours or H for hours
    • Minute, Minutes or m for minutes
    • Second, Seconds or s for seconds
    • Millisecond, Milliseconds or A for milliseconds
  2. Amount to add as a long. It can be a negative value to subtract an amount of time.
  3. Input datetime.
Expression: addToDateTime("M", -1, "2021-03-21T10:19:26.214+02:00")

Result: 2021-02-21T10:19:26.214+02:00

extractFromDateTime Extracts part of a datetime or date. If the first argument is a date, it is first converted to a datetime with the time set to noon in the local time zone.
  1. Input date or datetime.
  2. Unit to extract as a string:
    • Date for the full date
    • Time for the full time
    • Year, Years, Y or u for the year
    • Month, Months, M or L for the month
    • Week, Weeks or W for the week of month
    • Week of Year or w for the week of year
    • Day, Days or d for the day
    • Day of Year or D for the day of year
    • Day of Month for the day of month
    • Day of Week, e or E for the day of week
    • Hour, Hours or H for the hour
    • Minute, Minutes or m for the minute
    • Second, Seconds or s for the second
    • Millisecond, Milliseconds or A for the millisecond
    • TimeZone, V or z for the time zone
Expression: extractFromDateTime("2021-03-21T10:19:26.214+02:00", "Time")

Result: 10:19:26.214

getCurrentDateTime Returns the current datetime. None Expression: getCurrentDateTime()

Possible result: 2021-04-21T10:32:44.851+02:00

parseDateTime Creates a datetime from a string.
  1. Input datetime as a string.
  2. Datetime pattern as a string:
    • yyyy for the year
    • MM for the month
    • dd for the day
    • HH for the hours
    • mm for the minutes
    • ss for the seconds
    • SSS for a fraction of a second
    • ZZZZZ for the time zone
Expression: parseDateTime("2021-04-21T11:05:18.337+02:00", "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ")

Result: 2021-04-21T11:05:18.337+02:00

isToday Returns true if the input date or datetime corresponds to the current date. Input date or datetime. Expression: isToday(getCurrentDateTime())

Result: true

isTomorrow Returns true if the input date or datetime corresponds to the next day. Input date or datetime. Expression: isTomorrow(addToDateTime("d", 1, getCurrentDateTime()))

Result: true

isYesterday Returns true if the input date or datetime corresponds to the previous day. Input date or datetime. Expression: isYesterday(addToDateTime("d", -1, getCurrentDateTime()))

Result: true