To register for the forums, please contact your Digital-Clay representative.

Calculate previous Date from days or weeks range

Community-oriented help and tech-support for the Digital-Clay platform.
Post Reply
eclectus
Posts: 15
Joined: Fri Dec 24, 2010 12:33 pm

Calculate previous Date from days or weeks range

Post by eclectus »

I have a form that has two fields - one is a number value and the other a list with 'days' 'weeks' 'months'.

The user enters a number and I have to calculate a previous date based on that input.

eg: the user enter 10 days, so I have to calculate the date of 10 days before the current date. The same if they pick 3 weeks, I would need the Date for three weeks before today. And the same with months.
ZevToledano
Posts: 722
Joined: Fri Apr 03, 2009 2:29 pm

Re: Calculate previous Date from days or weeks range

Post by ZevToledano »

So build a custom function with two 'ifs' (depending on days/weeks/months), then use the AddDays/AddWeeks/AddMonths functions with the date+numeric fields as the parameters.
eclectus
Posts: 15
Joined: Fri Dec 24, 2010 12:33 pm

Re: Calculate previous Date from days or weeks range

Post by eclectus »

well, I need to AddDays(-10) in my example:
1) does the function work to calculate backwards?
2) how do I use the value of the numeric field and give it a negative sign?
ZevToledano
Posts: 722
Joined: Fri Apr 03, 2009 2:29 pm

Re: Calculate previous Date from days or weeks range

Post by ZevToledano »

1. Yes
2. 0 - field
Post Reply