Geeks With Blogs
Pankaj Tahiliani datename
DateName vs DatePart
DATENAME function is used to get string of the specified datepart of the specified date.DATEPART Return of the specified date an integer that represents a specific dateConsider a problem where we have to converting a date to display in the MON YYYY format where "MON" is the 3 character month such as "Jan", "Feb", "Mar", etc.use NORTHWIND;SELECT CASE DATEPART(mm,OrderDate) WHEN 01 THEN 'Jan' WHEN 02 THEN 'Feb' WHEN 03 THEN 'Mar' WHEN 04 THEN 'Apr' WHEN 05 THEN 'May' WHEN 06 THEN 'Jun' WHEN 07 THEN ......

Posted On Saturday, July 20, 2013 10:41 PM

Copyright © Pankaj Tahiliani | Powered by: