Wyn Enterprise User Guide

Date and Time Functions

These functions are very similar to the date and time functions of Microsoft Excel. You can use these functions to extract dates, calculate the difference between two dates, find the current date and time, and much more.

Following is the list of date and time functions supported in Wyn Enterprise:

DATE


Description

The DATE function returns the specified date in the datetime format.

Syntax

DATE(<year>,<month>,<day>) 

Parameters

Term Description
year A four-digit number representing a year.
month A number ranging from 1 to 12 represents the month of the year.
day A number ranging from 1 to 31 represents the day of the year.

Return Value

A specified date (datetime).

Example

DATE(2012,12,12) 

DATEDIFF


Description

The DATEDIFF function returns the number of units (unit specified in Interval) between the input two dates.

Syntax

DATEDIFF(<start_date>, <end_date>, <interval>)

Parameters

Term Description
start_date A date in datetime format representing the start date.
end_date A date in datetime format representing the start date.
interval A unit to use for comparing dates. The possible values are SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR.

Return Value

The count of interval boundaries crossed between two dates.

Example

DATEDIFF('Sale'[Order Date], TODAY(), DAY)

DAY


Description

The DAY function returns a number from 1 to 31 representing the day of the month.

Syntax

DAY(<date>)

Parameters

Term Description
date A date in datetime format.

Return Value

An integer value ranging from 1 to 31.

Example

DAY('Sale'[Sale Date])

HOUR


Description

The HOUR function returns the hour as a number from 0 (12:00 A.M.) to 23 (11:00 P.M.).

Syntax

HOUR(<datetime>)

Parameters

Term Description
datetime A datetime value, such as 16:48:00 or 4:48 PM.

Return Value

An integer value ranging from 0 to 23.

Example

HOUR('Sale'[Sale DateTime])

MINUTE


Description

The MINUTE function returns a number from 0 to 59 representing the minute.

Syntax

MINUTE(<datetime>)

Parameters

Term Description
datetime A datetime value or text in an accepted time format, such as 16:48:00 or 4:48 PM.

Return Value

An integer value ranging from 0 to 59.

Example

MINUTE('Sale'[Sale DateTime])

MONTH


Description

The MONTH function returns a number from 1 (January) to 12 (December), representing the month.

Syntax

MONTH(<date>)

Parameters

Term Description
date A date in datetime or text format.

Return Value

An integer value ranging from 1 to 12.

Example

MONTH('Sale'[Sale Datetime])

NOW


Description

The NOW function returns the current date and time in datetime format. The NOW function is useful when you need to display the current date and time on a worksheet or calculate a value based on the current date and time, and have that value updated each time you open the worksheet.

Syntax

NOW()  

Return Value

A date (datetime).

Example

NOW()

QUARTER


Description

The QUARTER function returns a number ranging from 1 (January-March) to 4 (October-December) representing the quarter.

Syntax

QUARTER(<date>)

Parameters

Term Description
date A date.

Return Value

An integer value ranging from 1 to 4.

Example

QUARTER('Sale'[Sale Date])

SECOND


Description

The SECOND function returns a number from 0 to 59 representing the second.

Syntax

SECOND(<datetime>)

Parameters

Term Description
datetime A time in datetime format.

Return Value

An integer value ranging from 0 to 59.

Example

SECOND(now())

TODAY


Description

The TODAY function returns the current date in datetime format.

Syntax

TODAY()  

Return Value

A date (datetime).

Example

TODAY()

WEEKDAY


Description

The WEEKDAY function returns a number identifying the day of the week of a date. The value ranges from 1 (Sunday) to 7 (Saturday).

Syntax

WEEKDAY(<datetime>)

Parameters

Term Description
datetime A time in datetime format.

Return Value

An integer value ranging from 1 to 7.

Example

WEEKDAY(now())

WEEKNUM


Description

The WEEKNUM function returns the week number for the given date according to the return_type value. The week number indicates where the week falls numerically within a year.

Syntax

WEEKNUM(<datetime>,<returnType>)

Parameters

Term Description
datetime A time in datetime format.
returnType An integer number (0 or 1) that determines on which day the week begins.
• 0 (Sunday): Western traditional
• 1(Monday): ISO-8601

Return Value

An integer.

Example

WEEKNUM(now(),1)

YEAR


Description

The YEAR function returns the year of a date as a four-digit integer in the range 1900-9999.

Syntax

YEAR(<date>)

Parameters

Term Description
date A date in datetime or text format, containing the year you want to find.

Return Value

An integer in the range 1900-9999.

Example

Year('Sale'[Sale Datetime])