Technical Article

Date format

,

Date format according to current Language setting. excludes time.

/*
I was trying to get two different version of Date Format i.e. 'mon dd yyyy' and 'dd mon yyyy'
according to the current language settings. 

Actually one of my colleagues wrote initial code. I just made it more useful for me.

This code checks the date format according to  Language currently in use
Checked it with English US and Spanish languages.

Please give ur suggestions/updations.
*/Declare @vcDateTime varchar(12)

-- if its 'mon dd yyyy'
if (select left(dateformat,1) from master..syslanguages where name = @@language) = 'm'
 select @vcDateTime = convert(varchar,getdate(), 9)
else
-- if its 'dd mon yyyy'
if (select left(dateformat,1) from master..syslanguages where name = @@language) = 'd'
 select @vcDateTime = convert(varchar,getdate(), 13)
-- ah! the default case. Use the ISO8601 standard.
else
 select @vcDateTime = convert(varchar,getdate(), 126)
 Select @vcDateTime

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating