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 2005 Forums
 Transact-SQL (2005)
 covert date

Author  Topic 

palak
Yak Posting Veteran

55 Posts

Posted - 2008-04-18 : 08:29:19
how to convert date like :-9/2009 - to- 2009-01-09 00:00:00.000

thanks.

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-04-18 : 08:50:03
One way...

set dateformat dmy
select cast('1/'+'9/2009' as datetime)


Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-18 : 08:53:10
quote:
Originally posted by RyanRandall

One way...

set dateformat dmy mdy
select cast('1/'+'9/2009' as datetime)


Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-04-18 : 08:55:26
quote:
mdy
Oops - good point madhi.

Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

palak
Yak Posting Veteran

55 Posts

Posted - 2008-04-18 : 09:31:56
thanks guys RyanRandall & madhivanan

thanks a lot!!!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-18 : 10:07:28
quote:
Originally posted by palak

thanks guys RyanRandall & madhivanan

thanks a lot!!!


But always use proper DATETIME datatype to store dates

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -