2 Replies Latest reply on Mar 22, 2013 8:03 AM by JimMac

# Date Calculation

### Title

Date Calculation

### Post

Hi All,

Could anyone please write me a calculation for... (I don't know if it even possible??)

I have fields

1. Current Date

2. Current Date +- 1 week  (Wendsday)

3. Current Date +- 2 weeks  (Wendsday)

4. Current Date +-3 weeks  (Wendsday)

5. Current Date +- 5 weeks  (Wendsday)

6. Current Date +- 12 weeks  (Wendsday)

And i want to calculate a in fields 2-6 date that always will be WENDSDAY

So for exm. if today is 22.mar.2013 in field 2 i would like to generate 27 mar. 2013 wendsday

Thanks a LOT!

• ###### 1. Re: Date Calculation

I am not sure what  you exactly want.  If you mean you want the next future Wednesday  after you make the Weeks calculation then make your calculation for the Increment/Decrement first by this...

BTW...  I will not code it for you... but guide you to see how it is done...

CalculatedDate = Currentdate  + NumberOfWeeks *  7  //  assumes that the decrement is minus signed.

Using a Date Function...

DayOfWeek
Purpose
Returns a number representing the day of the week that date falls on.

Sunday = 1.... Wednesday = 4

DaysFromWednesday = 4 - DayOfWeek( CalculatedDate )

FutureWednesday = CalculatedDate  + If ( DayOfWeek( CalculatedDate ) ≥ 0;  DaysFromWednesday ;  7 + DaysFromWednesday )

This may not be what you are after, but gives you the idea how to use Date functions...
Jim....

• ###### 2. Re: Date Calculation

ooppps I need a second cup of coffee.....

FutureWednesday = CalculatedDate  + If ( DaysFromWednesday ≥ 0;  DaysFromWednesday ;  7 + DaysFromWednesday )

corrected...

Jim...