Friday, February 24, 2012

Format date time

declare @.d smalldatetime
declare @.e varchar(8)
set @.d='1/8/2005'
set @.e=.........?
I wanna set @.e with format 'YYYYMMDD' of @.d. How?One method:
SET @.e = CONVERT(varchar(8), @.d, 112)
You also might consider using the YYYYMMDD format in your date literal
strings in order to avoid ambiguity.
Hope this helps.
Dan Guzman
SQL Server MVP
"Bpk. Adi Wira Kusuma" <adi_wira_kusuma@.yahoo.com.sg> wrote in message
news:u9UckoYkFHA.1044@.tk2msftngp13.phx.gbl...
> declare @.d smalldatetime
> declare @.e varchar(8)
> set @.d='1/8/2005'
> set @.e=.........?
> I wanna set @.e with format 'YYYYMMDD' of @.d. How?
>

No comments:

Post a Comment