Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date Format
Message
De
30/04/2003 12:16:31
 
 
À
30/04/2003 10:58:55
Alvin Lourdes
Children and Youth Services Cluster
Toronto, Ontario, Canada
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
00783178
Message ID:
00783224
Vues:
15
You'll have to use the Convert() function to remove the time part, the datetime datatype always returns the time part as well. For your search, you'll have to remove the time part, because to SQL Server '4/11/2003 9:12:20 AM' is not the same as '4/11/2003'.
declare @dt datetime
set @dt = '4/11/2003 9:12:20 AM'

-- return date only as a string
select Convert(varchar(12), @dt,101)
-- remove time part
select Cast(Convert(varchar(12), @dt,101) as datetime)
Roman

>Hi,
>
>I have a datetime field, when I query this field I get something like this
>4/11/2003 9:12:20 AM
>
>I would like to return only the full date portion of this field.
>
>
>Also,
>
>When I perform a search on this field... if I look for 04/11/2003 will I get the appropriate row?
>
>
>Thanks,
>
>Sorry if the question is worded badly.. Im trying to get this done..
>
>Thanks,
>
>Alvin
Roman Rehak, MCSD, MCDBA, MCSA
Competitive Computing
354 Mountain View Drive
Colchester, VT 05446-5824
802-764-1729
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform