sql server - How to format date to a certain way in SQL -
i have following query:
select dateadd(day, 0 - (datepart(weekday, getdate()) % 7), getdate())
which displays:
2014-04-19 10:47:46.790
how can modify query displays 04/19/2014
or 04-19-2014
select convert(varchar, dateadd(day, 0 - (datepart(weekday, getdate()) % 7), getdate()), 101)
outputs
04/19/2014
and
select convert(varchar, dateadd(day, 0 - (datepart(weekday, getdate()) % 7), getdate()), 110)
outputs
04-19-2014
alternately, format in consuming application (in case, ssrs). done
=format(date_column, "mm/dd/yyyy")
or
=format(date_column, "mm-dd-yyyy")
Comments
Post a Comment