part)
This function is similar to DATEPART and in fact has the same options for the part input. However,
when relevant, it returns the name of the requested part rather than the number. For example, the
following code returns the month name of the given input value.
SELECT DATENAME(month, '20090212');
Recall that DATEPART returned the integer 2 for this input. DATENAME returns the name of the
month, which is language dependent. If your session’s language is one of the English languages
(such as U.S. English or British English), you get back the value ‘February’. If your session’s language is
Italian, you get back the value ‘febbraio’. If a part is requested that has no name, but only a numeric
value (such as year), the DATENAME function returns its numeric value as a character string. For ex-
ample, the following code returns ‘2009’.
SELECT DATENAME(year, '20090212');
Do'stlaringiz bilan baham: |