Skip to main content

EXAMPLE - DATE and TIME Functions

This example provides an overview on various date and time functions.

Functions:

Item

Description

DATE Function

Generates a date value from three inputs of Integer type: year, month, and day.

TIME Function

Generates time values from three inputs of Integer type: hour, minute, and second.

DATETIME Function

Generates a Datetime value from the following inputs of Integer type: year, month, day, hour, minute, and second.

DATEFORMAT Function

Formats a specified Datetime set of values according to the specified date format. Source values can be a reference to a column containing Datetime values.

Source:

year

month

day

hour

minute

second

2016

10

11

2

3

0

2015

11

20

15

22

30

2014

12

25

18

30

45

Transformation:

Transformation Name

New formula

Parameter: Formula type

Single row formula

Parameter: Formula

DATEFORMAT(DATE (year, month, day),'yyyy-MM-dd')

Parameter: New column name

'fctn_date'

Transformation Name

New formula

Parameter: Formula type

Single row formula

Parameter: Formula

DATEFORMAT(TIME (hour, minute, second),'HH-mm-ss')

Parameter: New column name

'fctn_time'

Transformation Name

New formula

Parameter: Formula type

Single row formula

Parameter: Formula

DATEFORMAT(DATETIME (year, month, day, hour, minute, second),'yyyy-MM-dd-HH:mm:ss')

Parameter: New column name

'fctn_datetime'

Results:

注意

All inputs must be inferred as Integer type and must be valid values for the specified input. For example, month values must be integers between 1 and 12, inclusive.

year

month

day

hour

minute

second

fctn_date

fctn_time

fctn_datetime

2016

10

11

2

3

0

2016-10-11

02-03-00

2016-10-11-02:03:00

2015

11

20

15

22

30

2015-11-20

15-22-30

2015-11-20-15:22:30

2014

12

25

18

30

45

2014-12-25

18-30-45

2014-12-25-18:30:45

You can apply other date and time functions to the generated columns. For an example, see YEAR Function.