Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Last day of Date

Author  Topic 

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-01-07 : 02:28:55
Hi,
I want to write a query that calculates the difference between a given date and last day of currentdate.
eg
Given date 15 sep 2004
Current date 07 jan 2004

I want the number of days between givendate and 31 jan 2004

I used DateDiff('d',givendate,(DateAdd('m',1,#31 Jan 2005#), DatePart('d',#31 Jan 2005#)) but it works only the datepart of jan is 28 as last day of february is 28

any help?

Madhivanan

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2005-01-07 : 06:36:51
DateDiff("d", "11.01.2005", DateAdd("m", 1, Date) - Day(DateAdd("m", 1, Date)))

.. and answer is 20..

hth
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-01-07 : 06:45:55
Thanks stoad. It works well

Madhivanan
Go to Top of Page
   

- Advertisement -