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)
 need to replace Minutes and seconds with 00:00

Author  Topic 

venkath
Posting Yak Master

202 Posts

Posted - 2008-02-05 : 09:46:47
Hi all

I need to display date values in 24 hours format and the minutes and seconds in the date value should be replaced with 00:00


getdate() - 2008-02-05 20:12:51.413 value should be displayed as

2008-02-05 20:00:00.000

Thanks in advance.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-05 : 09:48:49
SELECT DATEADD(DAY, DATEDIFF(DAY, '19000101', GETDATE()), '19000101'),
DATEADD(HOUR, DATEDIFF(HOUR, '19000101', GETDATE()), '19000101'),
DATEADD(MINUTE, DATEDIFF(MINUTE, '19000101', GETDATE()), '19000101')


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-05 : 09:48:54
DATEADD(d,DATEDIFF(d,0,GETDATE()),0)
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-02-05 : 10:48:50
[code]
select DT = dateadd(hh,datediff(hh,0,getdate()),0)

Results:
DT
------------------------------------------------------
2008-02-05 10:00:00.000

(1 row(s) affected)
[code]

CODO ERGO SUM
Go to Top of Page
   

- Advertisement -