Home All Groups Group Topic Archive Search About

Date Conversion to YYYYMMDD

Author
3 Aug 2006 2:11 PM
wnfisba
I have to convert a datetime column to YYYYMMDD format in an extract I'm
performing.

I checked SQL Server Books Online and there does not seem to be a conversion
style for YYYYMMDD.

Can anyone help me with the SQL here? Is there any way to convert this date
to YYYYMMDD format? Should I be using SUBSTRING instead???

Any help would be greatly appreciated.

Thanks.

wnfisba

Author
3 Aug 2006 2:15 PM
Uri Dimant
Use CONVERT function which has  a style parameter






Show quote
"wnfisba" <wnfi***@discussions.microsoft.com> wrote in message
news:82553391-2A59-49EC-AEC2-522F4B3B9CFE@microsoft.com...
>I have to convert a datetime column to YYYYMMDD format in an extract I'm
> performing.
>
> I checked SQL Server Books Online and there does not seem to be a
> conversion
> style for YYYYMMDD.
>
> Can anyone help me with the SQL here? Is there any way to convert this
> date
> to YYYYMMDD format? Should I be using SUBSTRING instead???
>
> Any help would be greatly appreciated.
>
> Thanks.
>
> wnfisba
Author
3 Aug 2006 2:15 PM
SQL Menace
use convert with style 112 (ISO)

select convert(varchar(8),getdate(),112)

Denis the SQL Menace
http://sqlservercode.blogspot.com/

wnfisba wrote:
Show quote
> I have to convert a datetime column to YYYYMMDD format in an extract I'm
> performing.
>
> I checked SQL Server Books Online and there does not seem to be a conversion
> style for YYYYMMDD.
>
> Can anyone help me with the SQL here? Is there any way to convert this date
> to YYYYMMDD format? Should I be using SUBSTRING instead???
>
> Any help would be greatly appreciated.
>
> Thanks.
>
> wnfisba
Author
3 Aug 2006 2:22 PM
Omnibuzz
Won't this work?

select convert(varchar(8),getdate(),112)

--
-Omnibuzz (The SQL GC)

http://omnibuzz-sql.blogspot.com/



Show quote
"wnfisba" wrote:

> I have to convert a datetime column to YYYYMMDD format in an extract I'm
> performing.
>
> I checked SQL Server Books Online and there does not seem to be a conversion
> style for YYYYMMDD.
>
> Can anyone help me with the SQL here? Is there any way to convert this date
> to YYYYMMDD format? Should I be using SUBSTRING instead???
>
> Any help would be greatly appreciated.
>
> Thanks.
>
> wnfisba

AddThis Social Bookmark Button