Is there an implemented way to retrieve separately day, month and year from a Date field in T-SQL? Everything I’ve found is to make the process the other way around, in my case I mean if I have 2012-05-22 I would like to have 3 different methods to get as a result 2012, 05 and 22 respectively.
Thanks in advance.
If it’s SQL Server, you can use
DATEPART(MSDN: http://msdn.microsoft.com/en-us/library/ms174420.aspx)Example: