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)
 max date

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_EP

so 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]
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-06-25 : 05:50:55
not sure is there any performance difference. Try it

select 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]

Go to Top of Page

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)
Go to Top of Page

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 query

And 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]

Go to Top of Page
   

- Advertisement -