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
 SQL Server Development (2000)
 Julian Date Logic

Author  Topic 

abhit_kumar
Posting Yak Master

147 Posts

Posted - 2008-12-01 : 06:49:34
I want to return in such a way that it will get -1 day from entered date. Following are of some examples, which i have to get return.

If i enter date = 4-1-2006
then result should be = 3-31-2006.

Enter Date = 1-1-2007
then result should be = 12-31-2006

Enter Date = 5-1-2006
then result should be = 4-30-2006

>In short, if the current date is the 1st of a month, subtracting “1” returns the last day of the prior month, regardless of whether that is the 28th, 29th, 30th, or 31st.

Please help me.

Thanks,
Abhi
Enter Date = 11-25-2006
then result should be = 11-24-2006

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-01 : 07:13:07
just use

SELECT DATEADD(dd,-1,@Date)

@Date is the entered date
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-12-01 : 07:23:21
or @Date-1

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -