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
 how to convert a varchar in datetime?

Author  Topic 

landau66
Yak Posting Veteran

61 Posts

Posted - 2008-07-04 : 09:47:42
hi everyone!

i have two columns. both are varchar fields.

date:
2008-06-25

time:
09:04:36

i would like to convert both columns into datetime fields and as a next step i would like to integrate both fields into one.

many thanks in advance and greetings from vienna

landau

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-07-04 : 09:54:23
declare @datefield varchar(10)
declare @timefield varchar(8)

select @datefield ='2008-06-25'
select @timefield = '09:04:36'

--set language english
select convert(datetime,@datefield + ' ' + @timefield)


There are 10 types of people in the world: Those who understand binary, and those who don't...
Go to Top of Page
   

- Advertisement -