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
 General SQL Server Forums
 New to SQL Server Programming
 similar to trunc in oracle

Author  Topic 

dsscholar
Starting Member

6 Posts

Posted - 2011-09-27 : 05:38:34
Hi all,

I have a timestamp in the format of 12-12-2011 10:12:12. I want to convert it into 12-12-2011 00:00:00. How to do this in sql server.

Thanks in advance.

Ranjit.ileni
Posting Yak Master

183 Posts

Posted - 2011-09-27 : 05:43:27
I am not sure,
Is this work out?

select left('12-12-2011 10:12:12',10)+' 00:00:00'

or

select left('12-12-2011 10:12:12',11)+'00:00:00'

--Ranjit
Go to Top of Page

vmvadivel
Yak Posting Veteran

69 Posts

Posted - 2011-09-27 : 06:17:48
--Replace getdate() with your datetime column
SELECT DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0)


Best Regards
Vadivel

http://vadivel.blogspot.com
Go to Top of Page
   

- Advertisement -