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
 SQL Functions

Author  Topic 

GB
Starting Member

22 Posts

Posted - 2005-08-25 : 09:56:35
Iam trying to convert a date string to date format.....in access I could just use CDate, but SQL apparently does not allow this.
Any help appreciated
Thanks

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-08-25 : 10:00:49
You can use CAST or CONVERT functions (see details in Books Online)

select cast('1/1/2000' as datetime) castDate, convert(datetime, '1/1/2000') convertedDate

EDIT:
I assume you mean convert a string to a datetime datatype.
(or did you mean keep it a string but a different style of date format?)

Be One with the Optimizer
TG
Go to Top of Page

GB
Starting Member

22 Posts

Posted - 2005-08-25 : 10:19:11
Yes convert from string to date time format
I have 2 seperate columns, "Date" and "Time"
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-08-25 : 10:27:52
ok, see your other topic for an example:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=54317

Be One with the Optimizer
TG
Go to Top of Page

GB
Starting Member

22 Posts

Posted - 2005-08-25 : 10:43:52
Thanks, sorry for the crosspost
Go to Top of Page
   

- Advertisement -