Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date conversion
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01242382
Message ID:
01242403
Vues:
10
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform