DATE_UNITVALUE function

The Klipfolio DATE_UNITVALUE function retrieves the value of a given unit from the given dates.

The syntax for the DATE_UNITVALUE function is:

DATE_UNITVALUE( values , unit , first, timezone ) 

Parameters

values The data set number vector
unit

Options include:

second, minute, hour, day, day of week, day of year, week, week of month, month, quarter, year.

number scalar
first

Optional

Options include:

Sunday (default), Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.

January (default), February, March, April, May, June, July, August, September, October, November, December.

Note: The day of the week options for first only affect calculations when unit is 'week of month' or 'week'. The month options for first only affect calculations when unit is 'day of year' or 'month' or 'quarter'.

text scalar
timezone

Optional

The timezone specified by region or offset.

text scalar

DATE_UNITVALUE example

Let's look at a DATE_UNITVALUE function example.

 

A

B

1 5/16/14 899
2 5/15/14 901
3 5/14/14 666

The following example is based on the above text in an Excel spreadsheet where today's date is 5/16/14:

SELECT( B:B , ( DATE_UNITVALUE( TODAY( ) , day ) = DATE_CONVERT( A:A , "M/d/yy" , "d" )))   

-> ["899"]

Result: Returns the value for today's date.

Related links: