Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula Question 1

Status
Not open for further replies.

northw

MIS
Nov 12, 2010
140
US
Hi all,
I Have a question regarding a formula,
Local DateVar d1 := (CurrentDate);
Local DateVar d2;
d2 := DateSerial(Year(d1), Month(d1) + 1, 1 - 1);
d2 - (DayOfWeek(d2, crFriday) - 1)
The above mentioned formula gives me exactly what I need, i.e. date of last friday of the month.

But, Below mentioned formula is same as the above, except the declaration of variables, but this formula gives me different result.
DateSerial(Year(CurrentDate), Month(CurrentDate) + 1, 1 - 1) -(DayOfWeek(CurrentDate, crFriday) - 1)

Please suggest me whats wrong here.

Thanks in advance.
 
The formula are not identical

In you second formual you have used

-(DayOfWeek(CurrentDate, crFriday) - 1)

but in the first formula you have

(DayOfWeek(d2, crFriday) - 1)

d2 is not current date but the last day of the month.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top