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.
Author |
Topic |
MageshkumarM
Yak Posting Veteran
61 Posts |
Posted - 2013-02-08 : 02:42:29
|
Hi all,I hav a datas below mentioned2010-01-01 JackSon 25.62010-01-02 Stack 230.12010-01-04 Steven 23.12010-01-05 Bell 2.112010-01-07 Clerk 30.12010-01-08 June 1.1I'm try to find previous date, could please help me abt this. |
|
MageshkumarM
Yak Posting Veteran
61 Posts |
Posted - 2013-02-08 : 02:43:49
|
I'm trying to retrieve date = '2010-01-07' and i expect previous day date.Thanks,Magesh.Mhttp://mageshkumarm.blogspot.com/ |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2013-02-08 : 02:52:00
|
where date_col>=dateadd(day,datediff(day,0,getdate()),-1) and date_col<dateadd(day,datediff(day,0,getdate()),0)MadhivananFailing to plan is Planning to fail |
|
|
MageshkumarM
Yak Posting Veteran
61 Posts |
Posted - 2013-02-08 : 03:40:30
|
sorry, where the condition check with date '2010-01-07'.I'm not get the previous day date..Thanks,Magesh.Mhttp://mageshkumarm.blogspot.com/ |
|
|
MageshkumarM
Yak Posting Veteran
61 Posts |
Posted - 2013-02-08 : 04:52:34
|
any one help me out of thisThanks,Magesh.Mhttp://mageshkumarm.blogspot.com/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-08 : 05:12:45
|
[code]SELECT Datefield AS YourDate,t1.PrevDate AS PreviousDateFROM YourTable tOUTER APPLY (SELECT MAX(DateField) AS PrevDate FROM YourTable WHERE datefield < t.Datefield)t1[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
MageshkumarM
Yak Posting Veteran
61 Posts |
Posted - 2013-02-08 : 05:43:05
|
make sense this statement.. thk u so muchThanks,Magesh.Mhttp://mageshkumarm.blogspot.com/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-08 : 05:55:23
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|