Share via


I want to get one day before date from my table

Question

Monday, December 30, 2013 10:23 AM

Hi ,
i have one table called `MYTABLE` and column called `MYDATE`

now I want a previous date of `MYDATE`

so did query like 

`SELECT dateadd(day,datediff(day,1,b.MYDATE),0), DeliveryDate from MYTABLE b`

It is working perfect but not giving me time 

NEW MYDATE
2013-06-04 00:00:00.000 2013-06-05 18:30:00.000

I want time also please correct me in above sql.

Ashish Fugat (ashuthinksatgmail.com) SE

All replies (2)

Monday, December 30, 2013 10:25 AM âś…Answered | 1 vote

SELECT b.MYDATE-1  AS prevdate, DeliveryDate from MYTABLE borSELECT DATEADD(dd,-1,b.MYDATE) AS prevdate,DeliveryDate from MYTABLE

provided MyDATE is of datetime datatype

Please Mark This As Answer if it helps to solve the issue Visakh http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs


Monday, December 30, 2013 10:28 AM

great :) thanks a lot

Ashish Fugat (ashuthinksatgmail.com) SE