Skip to main content

How to get parts of a date

These Calculated Field expressions pull one part out of a date and return it as a number. They use JavaScript's built-in Date methods, so the Field must hold a date value. Replace fieldAliasGoesHere with the alias of your date Field.

Get the month​

The month is returned as a number from 0 to 11, so January is 0 and August is 7.

// Date: August 6, 2022
// Result: 7

var date = $record['fieldAliasGoesHere'];
var month = date.getMonth();

month;

Get the year​

// Date: August 6, 2022
// Result: 2022

var date = $record['fieldAliasGoesHere'];
var year = date.getFullYear();

year;

Get the day of the week​

The day of the week is returned as a number from 0 to 6, where 0 is Sunday. August 6, 2022 was a Saturday.

// Date: August 6, 2022
// Result: 6

var date = $record['fieldAliasGoesHere'];
var day = date.getDay();

day;

Get the day of the month​

The day of the month is returned as a number from 1 to 31.

// Date: August 6, 2022
// Result: 6

var date = $record['fieldAliasGoesHere'];
var day = date.getDate();

day;