Re: Converting and formatting DATE field
From: John Bell (jbellnewsposts_at_hotmail.com)
Date: 02/27/04
- Next message: Scott Elgram: "Re: Stored procedure/trigger and scripts"
- Previous message: js: "Re: transaction?"
- In reply to: Olivia: "Converting and formatting DATE field"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Converting and formatting DATE field"
- Reply: anonymous_at_discussions.microsoft.com: "Re: Converting and formatting DATE field"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 27 Feb 2004 19:42:48 GMT
Hi
SQLServer does not have a date only datatype, therefore it will store a time
portion. If you don't specify the time portion when the datetime is inserted
it will be defaulted to 00:00:00.000. Without formatting the output you will
get a date and time. Try using:
SELECT CONVERT(char(10),col1,101) FROM MyTable
when you retrieve the data.
John
"Olivia" <anonymous@discussions.microsoft.com> wrote in message
news:336901c3fd66$8cba0a80$a501280a@phx.gbl...
> I need to load a string date data (from a text file) into
> a datetime type field.
>
> CONVERT(VARCHAR, COL1, 101) -- These one doesn't work
> because my destination field is a datatype and the load
> fails. No matter what style I use (100, 101, 102, etc)
>
> CONVERT(DATETIME, COL1, 101) -- This one, the load
> succeedes but no matter what style I use (100, 101, 102,
> etc) it always return the same date format:
> 2002-11-19 00:00:00.000
> I would like to be able to format this date and show only
> the date without time or uses mm/dd/yyyy or mm-dd-yyyy,
> etc.
>
> Thanks in advance for your help. Olivia
>
- Next message: Scott Elgram: "Re: Stored procedure/trigger and scripts"
- Previous message: js: "Re: transaction?"
- In reply to: Olivia: "Converting and formatting DATE field"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Converting and formatting DATE field"
- Reply: anonymous_at_discussions.microsoft.com: "Re: Converting and formatting DATE field"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|