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!

DateDiff function 1

Status
Not open for further replies.

alectek

Programmer
Jul 9, 2003
68
US
Hi!

{StartDate} = 07/01/2003
and {EndDate} = 01/31/2004

then the DateDiff("m", {StartDate}, {EndDate}) = 6

But, really it is 7.

I can use formula like
Round (({EndDate} - {StartDate})/30) and result will be 7.
Maybe somebody can give me more elegant solution.

Thank you very much.
Alex.
 
Try DateDiff("m", {StartDate}, {EndDate}) + 1

Naith
 
How many months would you expect :

{StartDate} = 07/31/2003
and {EndDate} = 01/01/2004 ??







Reebo
UK

Please Note - Due to current economic forcast and budget constraints, the light at the end of the tunnel has been switched off. Thank you for your cooperation.
 
To Reebo.
{EndDate} = 01/31/2004 and I expect 7 month? And you?

Thanks.
Alex.
 
sorry, I mean If the dates were from 31st July 2003 to 1st January 2004, how many months would you expect?

Personally, when showing the difference in months I don't take into account the day. Therefore :

1st July 2003 to 31st January 2004 = 6 Months
31st July 2003 to 1st January 2004 = 6 Months

If you want 1st July 2003 to 31st January 2004 = 7 Months then 31st July 2003 to 1st January 2004 = 5 Months ?






Reebo
UK

Please Note - Due to current economic forcast and budget constraints, the light at the end of the tunnel has been switched off. Thank you for your cooperation.
 
wowie --- must resist red flag of last post --- must resist

I ran into something similar a while back and it seems that the datediff was truely counting the number between - not including the end ( so - July, August, September, October, November, December was 6).

Knowing that I used it the way I wanted --- can't find the reference for that right now (sorry).
 
To Naith!
Thank you very much. Very easy solution and it's working even for one month.

Alex.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top