month function in the Factory

The month function returns the month value of date.


Parameters

month(date, extract)

Parameter

Description

date

The date, week, month, quarter or datetime attribute if the extract parameter is False to retrieve the month value.

If the extract parameter is True, all attribute types can be used. The date parameter is mandatory.

extract

A binary value (True/False) which is set as False as default.

If False, the function returns the month only, if True, the function returns also the corresponding year, if the date attribute is a date or datetime attribute.

The binary parameter values (True/False) are case sensitive.

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 Instagram_Data dataset.

Description

Screenshot

In this example, we want to retrieve the month and the year of the Date Posted attribute.

We add a new attribute, which is called Month Detail, and type the following formula:

month($"Date Posted",True)

and the attribute is filled not only with the month values, but also with the year values, as we specified True.