Manipulating Dates with Moment.js

Moment.js formulas let you manipulate stored Date Input values. You can reformat values, for example going from 2020/01/01 to January 1st, 2020. You can also add or subtract units of time, for example adding 7 days to a stored Date Input value.

Formatting Dates

Formatting formulas include tokens, like m, Do, or Y. These tokens represent a way to format your date information. To reformat stored Date Input values, use the following formula template: =moment(moment({Property ID/alias}),'format', '{tokens}'). For example =moment(moment(dateOne),'format', 'YY-MM-DD'). The following tables use Wednesday, January 9th, 1991 as a sample dateOne value.

Presets

 

Day

Token

Outcome

Possible Values

L

01/09/1991

01-12 / 01-31 / [Year]

l

1/9/1991

1-12 / 1-31 / [Year]

LL

January 9 1991

January-December 1-31 [Year]

ll

Jan 9 1991

Jan-Dec 1-31 [Year]

 

Token

Outcome

Possible Values

D

9

1 to 31

Do

9th

1st to 31st

DD

09

01 to 31

Day of the Week

 

Day of the Year

Token

Outcome

Possible Values

d

3

0 to 6 where Sunday = 0, and Saturday = 6

dd

We

Su to Sa

ddd

Wed

Sun to Sat

dddd

Wednesday

Sunday to Saturday

 

Token

Outcome

Possible Values

DDD

9

1 to 365

DDDo

9th

1st to 365th

DDDD

009

001 to 365

Week of the Year

 

Month

Token

Outcome

Possible Values

w

2

1 to 53

wo

2nd

1st to 53rd

ww

02

01 to 53

 

Token

Outcome

Possible Values

M

1

1 to 12

Mo

1st

1st to 12th

MM

01

01 to 12

MMM

Jan

Jan to Dec

MMMM

January

January to December

Quarter

 

Year

Token

Outcome

Possible Values

Q

1

1 to 4

Qo

1st

1st to 4th

 

Token

Outcome

Possible Values

YY

91

00-99

YYYY

1991

All years

You can also use field separators to visually chunk a date. Acceptable separators include the comma (,), forward slash (/), dash (-), period (.), or space ( ).

Manipulating Dates

To add or subtract units of time from stored Date Input values, use the following formula template: =moment(moment(moment({Property ID/alias}),'{add/subtract}',{number},'{unit(s) of time}'),'format','{tokens}'). For example: =moment(moment(moment(dateOne),'add',10,'days'),'format','YYYY-MM-DD'). The following tables, use the sample dateOne value of Wednesday, January 9th, 1991 (1991-01-09).

Add

 

Subtract

Formula

Outcome

=moment(moment(moment(dateOne),'add',3,'days'),'format','YYYY-MM-DD')

1991-01-12

=moment(moment(moment(dateOne),'add',2,'weeks'),'format','YYYY-MM-DD')

1991-01-23

=moment(moment(moment(dateOne),'add',1,'month'),'format','YYYY-MM-DD')

1991-02-09

 

Formula

Outcome

=moment(moment(moment(dateOne),'subtract',3,'days'),'format','YYYY-MM-DD')

1991-01-06

=moment(moment(moment(dateOne),'subtract',2,'weeks'')),'format','YYYY-MM-DD

1990-12-26

=moment(moment(moment(dateOne),'subtract',1,'month'),'format','YYYY-MM-DD')

1990-12-09