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)
 convert varchar to date

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2008-01-07 : 08:17:06
i have a date in the follwing format in a varchar field

19-11-2007 -- how can i convert this to a sql date so I can join it to another table where the dates are = (in the second table the date is a datetime field)

karthickbabu
Posting Yak Master

151 Posts

Posted - 2008-01-07 : 08:24:39

USING CONVERT Function like as below :

DECLARE @Str VARCHAR(10)
SET @Str = '19-11-2007'
SELECT CONVERT(DATETIME,@Str,105)

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-07 : 08:29:26
and if possible use proper DATETIME datatype for your parameter

Madhivanan

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

- Advertisement -