Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Adding a year to the current date field

Avatar

Level 8

Hello,

Can any one please help on how to add a year to the current date field.

e.g 7/19/2011 plus a year = 7/19/2012

Thanks,

Han Dao

1 Accepted Solution

Avatar

Correct answer by
Level 10

If you had a field DateTimeField1 and wanted to display the following year in DateTimeField2, you could do the following in JavaScript;

var d1 = util.scand("yyyy-mm-dd", DateTimeField1.rawValue);
if (d1 !== null)
{
d1.setFullYear(d1.getFullYear()+1);
DateTimeField2.rawValue = util.printd("yyyy-mm-dd", d1);
}

Good luck

Bruce

View solution in original post

0 Replies

Avatar

Correct answer by
Level 10

If you had a field DateTimeField1 and wanted to display the following year in DateTimeField2, you could do the following in JavaScript;

var d1 = util.scand("yyyy-mm-dd", DateTimeField1.rawValue);
if (d1 !== null)
{
d1.setFullYear(d1.getFullYear()+1);
DateTimeField2.rawValue = util.printd("yyyy-mm-dd", d1);
}

Good luck

Bruce