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
 assining string variable to a datetime column

Author  Topic 

venkath
Posting Yak Master

202 Posts

Posted - 2007-05-07 : 14:46:03
HI

can i assign a string column to a date column
string column contain date data.

UPDATE TABLE ENT SET EXPIRE_DATE = PREVIOUS_TRN_VALUE

where EXPIRE_DATE is a datetime column
PREVIOUS_TRN_VALUE is a string column having the value '2007-05-07'

thanks

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-07 : 14:51:01
[code]UPDATE ENT
SET EXPIRE_DATE = CAST(PREVIOUS_TRN_VALUE as DATETIME)
Where IsDate(PREVIOUS_TRN_VALUE) = 1[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

venkath
Posting Yak Master

202 Posts

Posted - 2007-05-07 : 15:38:09
I think it does implicit convertion to datetime..no need to covert explicitly


Thanks for your response.

Go to Top of Page
   

- Advertisement -