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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 need some help

Author  Topic 

a_shipra
Starting Member

20 Posts

Posted - 2004-07-29 : 23:59:47
Hi all,

I need some help with this.

Can you tell me in the select statement what is happening?

Declare @lastDate int
SELECT @lastdate = DAY(DATEADD(DAY,-1,DATEADD(MONTH,1,DATEADD(DAY,1-DAY(@when),@when))))

Thanks

shipra

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-07-30 : 00:21:09
Looks like it's calculating the end of the month (where the date is @when)

The inner-most one DATEADD(DAY,1-DAY(@when),@when)) gets the first day of the current month
The next one out gets the first day of the next month, and the outer-most one gets the previous day.

Go to Top of Page

a_shipra
Starting Member

20 Posts

Posted - 2004-07-30 : 00:27:11
Thanks for your help
Go to Top of Page
   

- Advertisement -