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 |
kemi2299
Starting Member
41 Posts |
Posted - 2008-06-25 : 05:09:49
|
hi,Could you pls take a look at this statement, its to do 2 things:first to get only maximum or latest episode date;the second is to ignore the time of the episode.select max_Ep_St_Dt=max(CONVERT(VARCHAR(10),Ep_St_Dt,103) from BLT_DATAWAREHOUSE.dbo.IM_IP_EPso far i am getting errors, |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-25 : 05:17:26
|
[code]select max_Ep_St_Dt=max(DATEADD(dd,DATEDIFF(dd,0,Ep_St_Dt),0)) from BLT_DATAWAREHOUSE.dbo.IM_IP_EP[/code] |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-06-25 : 05:50:55
|
not sure is there any performance difference. Try itselect max_Ep_St_Dt = DATEADD(day, DATEDIFF(day, 0, max(Ep_St_Dt)), 0) from BLT_DATAWAREHOUSE.dbo.IM_IP_EP KH[spoiler]Time is always against us[/spoiler] |
 |
|
kemi2299
Starting Member
41 Posts |
Posted - 2008-06-25 : 09:48:39
|
hi guys,thanks for your solution, its works partly on the time, however I am still getting duplicate records, its not choosing only the maximum date. Instead i am getting 2 dates for a patient record.max_Ep_St_Dt = DATEADD(day, DATEDIFF(day, 0, max(Ep_St_Dt)), 0) |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-06-25 : 09:54:49
|
quote: Originally posted by kemi2299 hi guys,thanks for your solution, its works partly on the time, however I am still getting duplicate records, its not choosing only the maximum date. Instead i am getting 2 dates for a patient record.max_Ep_St_Dt = DATEADD(day, DATEDIFF(day, 0, max(Ep_St_Dt)), 0)
Please post your full queryAnd please explain what do you mean by "Instead i am getting 2 dates for a patient record." KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|