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
| Article | In one line |
|---|---|
| How to compare dates | Check whether dates are the same, in order, or inside a range. |
| How to format a date | Turn a date into text in the pattern you choose. |
| How to add or subtract from a date | Move a date forward or back by days, months, or years. |
| How to get parts of a date | Pull out the month, year, day of the week, or day of the month. |