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.
To register for the forums, please contact your Digital-Clay representative.
Calculate previous Date from days or weeks range
-
ZevToledano
- Posts: 722
- Joined: Fri Apr 03, 2009 2:29 pm
Re: Calculate previous Date from days or weeks range
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.
Re: Calculate previous Date from days or weeks range
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?
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
1. Yes
2. 0 - field
2. 0 - field