Date Operators

Operator

Description

Example

$dayOfWeek

Returns the day of the week for the passed in date property or expression as a number from 1 (Sunday) to 7 (Saturday).

{"$dayOfWeek": "created"}

$dayOfMonth

Returns the day of the month for the passed in date property or expression as a number from 1 to 31

{"$dayOfMonth": "created"}

$dayOfYear

Returns the day of the year for the passed in date property or expression as a number from 1 to 366

{"$dayOfYear": "created"}

$year

Returns the year for the passed in date property or expression.

{"$year": "created"}

$month

Returns the month for the passed in date property or expression.

{"$month": "created"}

$week

Returns the week of the year for the passed in date property or expression as a number between 0 (the partial week that precedes the first Sunday of the year) and 53 (in a leap year).

{"$week": "created"}

$hour

Returns the hour for the passed in date property or expression as a number between 0 and 23.

{"$hour": "created"}

$minute

Returns the minute for the passed in date property or expression as a number between 0 and 59.

{"$minute": "created"}

$second

Returns the second for the passed in date property or expression as a number between 0 and 60 (for a leap second).

{"$second": "created"}

$millisecond

Returns the millisecond for the passed in date property or expression as a number between 0 and 999.

{"$millisecond": "created"}

$dateToString

Converts a date object to a string in a specified format, and expects an array of [<format>, date_expression][<format>, date_expression]

{ "$dateToString": ["%Y-%m-%d", "created"] }

Date Format Specifiers

Specifiers

Description

Possible Values

%d

Day of Month (2 digits, zero padded)

01-31

%G

Year in ISO 8601 format

0000-9999

%H

Hour (2 digits, zero padded, 24-hour clock)

00-23

%j

Day of year (3 digits, zero padded)

001-366

%L

Millisecond (3 digits, zero padded)

000-999

%m

Month (2 digits, zero padded)

01-12

%M

Minute (2 digits, zero padded)

00-59

%S

Second (2 digits, zero padded)

00-60

%u

Day of week number in ISO 8601 format (1-Monday, 7-Sunday)

1-7

%U

Week of year (2 digits, zero padded)

00-53

%V

Week of Year in ISO 8601 format

1-53

%w

Day of week (1-Sunday, 7-Saturday)

1-7

%Y

Year (4 digits, zero padded)

0000-9999

%%

Percent Character as a Literal

%