Sunday, February 19, 2012

date convert format question

ni need to convert a date given as
declare @.thsDate as datetime
set @.thsDate = getdate()
to an integer of YYYYMMDD
thanks
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kesAn INTEGER? WHY on earth would you want to do that?
SELECT CONVERT(CHAR(8), GETDATE(), 112)
"WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
news:051238CE-AFAD-4DA7-A0C4-C44E3F9E4190@.microsoft.com...
> ni need to convert a date given as
> declare @.thsDate as datetime
> set @.thsDate = getdate()
> to an integer of YYYYMMDD
> thanks
> kes
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes|||Try:
SELECT CONVERT(INT,CONVERT(VARCHAR(8),GETDATE()
,112))
HTH
Jerry
"WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
news:051238CE-AFAD-4DA7-A0C4-C44E3F9E4190@.microsoft.com...
> ni need to convert a date given as
> declare @.thsDate as datetime
> set @.thsDate = getdate()
> to an integer of YYYYMMDD
> thanks
> kes
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes|||sometimes you have to play the hand you are dealt. next version i'll flip it
all the date fields to dates but for now ...
and thanks
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Aaron Bertrand [SQL Server MVP]" wrote:

> An INTEGER? WHY on earth would you want to do that?
> SELECT CONVERT(CHAR(8), GETDATE(), 112)
>
> "WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
> news:051238CE-AFAD-4DA7-A0C4-C44E3F9E4190@.microsoft.com...
>
>

No comments:

Post a Comment