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
 date time

Author  Topic 

sushma patle
Starting Member

15 Posts

Posted - 2008-05-21 : 02:54:39
SELECT CAST(CONVERT(VARCHAR(10), GETDATE(), 108) AS DATETIME) AS [CurrentTime]
then output is

CurrentTime
-------------------------
1900-01-01 09:30:25.000

there date is 1900-01-01

why ?

spatle

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-05-21 : 03:04:44
because you are asking SQL Server to turn the time (in the CONVERT) back into a datetime. As there is no date part to the convert, this then takes the start date for SQL Server.

You could find this out yourrself by just running:

SELECT CONVERT(VARCHAR(10), GETDATE(), 108) AS [CurrentTime]
Go to Top of Page
   

- Advertisement -