sql server 2008 - What does the third parameter in CONVERT() do? -
query
get joining year,joining month , joining date employee table
this query have perform. write following script:
select substring (convert(varchar,joining_date,103),7,4) , substring (convert(varchar,joining_date,100),1,3) , substring (convert(varchar,joining_date,100),5,2) employee the result is: http://d.pr/i/vobi
but when changed convert(varchar,joining_date,100) convert(varchar,joining_date,101)
result this: http://d.pr/i/g5fz
can please explain parameter means?
there several different ways can format date using convert(varchar.... these documented on msdn site or different sites online.
using convert(varchar..., date, 100) places date in format:
mon dd yyyy hh:mmam (or pm) may 10 2013 12:55pm using convert(varchar...date, 101) puts date in format:
mm/dd/yyyy 05/10/2013 see demo
my suggestion whenever implement these conversions, sure give length on varchar(10), etc.
based on looks returning, can eliminate of convert/substring statements using , implement other functions same result:
select year(joining_date) [year] , convert(varchar(3),joining_date,100) [month] , day(joining_date) [day] employee
Comments
Post a Comment