Skip to main content

JavaScript Examples - Dates

Snippets for comparing, formatting, shifting, and taking apart date values. Each one is an expression for a Calculated Field Flow Step: it reads a Field from $record, and the value of its last line becomes the new Field's value. Replace the alias placeholders with the aliases of your date Fields.

Most of these snippets use Moment.js, which Informer scripts reach through the reserved moment variable (see Reserved Power Script variables). The rest use JavaScript's built-in Date methods.

In this section​

ArticleIn one line
How to compare datesCheck whether dates are the same, in order, or inside a range.
How to format a dateTurn a date into text in the pattern you choose.
How to add or subtract from a dateMove a date forward or back by days, months, or years.
How to get parts of a datePull out the month, year, day of the week, or day of the month.