day function

The day function returns the day value of the date.


Parameters

day(date)

Parameter

Description

date

The date, week, month, quarter, datetime attribute we want to use to cast the day. The date parameter is mandatory.

Date type valid formats (if the values aren’t this format, the function will return an error).

  • 2019/10/12;

  • 12/10/2019;

  • 2019-10-12;

  • 12-10-2019;

  • 2019/Oct/12;

  • 12/Oct/2019;

  • 2019-Oct-12;

  • 12-Oct-2019.

Week type valid formats (if the values aren’t this format, the function will return an error).

  • 2019/W41;

  • W41/2019;

  • 2019-W41;

  • W41-2019.

Month type valid formats (if the values aren’t this format, the function will return an error).

  • 1492/10;

  • 10/1492;

  • 1492-10;

  • 10-1492;

  • 1492/Oct;

  • 1492-Oct;

  • Oct/1492;

  • Oct-1492.

Quarter type valid formats (if the values aren’t this format, the function will return an error).

  • 2019/Q3;

  • Q3/2019;

  • 2019-Q3;

  • Q3-2019.

Datetime type valid formats (if the values aren’t this format, the function will return an error).

  • 2019/05/22 17:33:45


Example

The following example uses the Bike sales dataset.

Description

Screenshot

Suppose you don’t have already the Day attribute in this dataset and you want to extract only the day string from the Date attribute. Add a new attribute, called newday, and type the following formula:

day($"Date")

and the attribute will be filled with the day value of the Date attribute.

You can use the existing Day attribute to double check the results.