Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date conversion
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01242382
Message ID:
01242403
Views:
9
This message has been marked as the solution to the initial question of the thread.
>Boris:
>
>You example work but the data is not formated in the way you think, if the day is 7/1/2006 is saved as 7, 1, 2006 the single digit does not have 0 as 07, 01, 2006 so those values return null. Any idea?
DECLARE @Test TABLE (Yr varchar(50), Mnt varchar(50), Dday varchar(50))
INSERT INTO @Test VALUES ('2007', '7', '1')
INSERT INTO @Test VALUES ('bla bla', '07', '19')
SET DATEFORMAT DMY
SELECT CASE WHEN ISDATE(Dday+'/'+Mnt+'/'+Yr) = 1
             THEN CONVERT(datetime, Dday+'/'+Mnt+'/'+Yr)
             ELSE NULL END as DTField
FROM @Test
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform