FORMAT()-Returns formatted value of specific format. let's check with datetime format with sample data.
--Native method
select convert(varchar(12),getdate(),112)
--New Method
select format(getdate(),'yyyyMMdd')
select format(getdate(),'yyyy')
select format(getdate(),'MM-dd-yyyy')
select format(getdate(),'MM/dd/yyyy')
With the help of FORMAT Function we can format datetime format without using Convert/Cast.
For more info FORMAT Function.
--Native method
select convert(varchar(12),getdate(),112)
--New Method
select format(getdate(),'yyyyMMdd')
select format(getdate(),'yyyy')
select format(getdate(),'MM-dd-yyyy')
select format(getdate(),'MM/dd/yyyy')
With the help of FORMAT Function we can format datetime format without using Convert/Cast.
For more info FORMAT Function.
No comments:
Post a Comment