470,594 Members | 1,536 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

MySQL equivalent for MSSQL's DATENAME

Please help!

I am hunting high and low for an equivalent function for MSSQL's
DATENAME function. Here's the spec on the function from MSSQL's Books
Online:

DATENAME
Returns a character string representing the specified datepart of the
specified date.

Syntax
DATENAME ( datepart , date )

Arguments
datepart

Is the parameter that specifies the part of the date to return. The
table lists dateparts and abbreviations recognized by Microsoft® SQL
Server™.

Datepart Abbreviations
year yy, yyyy
quarter qq, q
month mm, m
dayofyear dy, y
day dd, d
week wk, ww
weekday dw
hour hh
minute mi, n
second ss, s
millisecond ms
The weekday (dw) datepart returns the day of the week (Sunday, Monday,
and so on).

Is an expression that returns a datetime or smalldatetime value, or a
character string in a date format. Use the datetime data type for dates
after January 1, 1753. Store as character data for earlier dates. When
entering datetime values, always enclose them in quotation marks.
Because smalldatetime is accurate only to the minute, when a
smalldatetime value is used, seconds and milliseconds are always 0. For
more information about specifying dates, see datetime and
smalldatetime. For more information about specifying time values, see
Time Formats.

If you specify only the last two digits of the year, values less than
or equal to the last two digits of the value of the two digit year
cutoff configuration option are in the same century as the cutoff year.
Values greater than the last two digits of the value of this option are
in the century that precedes the cutoff year. For example, if two digit
year cutoff is 2049 (default), 49 is interpreted as 2049 and 2050 is
interpreted as 1950. To avoid ambiguity, use four-digit years.

Return Types
nvarchar

Remarks
SQL Server automatically converts between character and datetime values
as necessary, for example, when you compare a character value with a
datetime value.

Examples
This example extracts the month name from the date returned by GETDATE.

SELECT DATENAME(month, getdate()) AS 'Month Name'

Here is the result set:

Month Name
------------------------------
February
See Also

CAST and CONVERT

Data Types

Date and Time Functions

©1988-2000 Microsoft Corporation. All Rights Reserved.

Feb 21 '06 #1
2 8862
>I am hunting high and low for an equivalent function for MSSQL's
DATENAME function. Here's the spec on the function from MSSQL's Books
Online:


MySQL's date_format() function appears to do similar things to
DATENAME. The format string is very different. If it's a constant
string (e.g. you're always going after the full month name), it
should be easy to translate.

Gordon L. Burditt
Feb 21 '06 #2
jb**********@gmail.com wrote:
Please help!

I am hunting high and low for an equivalent function for MSSQL's
DATENAME function. Here's the spec on the function from MSSQL's Books
Online:
Then I would have to say you did not search very hard :)

http://dev.mysql.com/ look at the documentation and search for the keyword date

<stuff removed> See Also

CAST and CONVERT

Data Types

Date and Time Functions


MySQL supports the ANSI standard CAST function that can accomplish the same thing.

--
Michael Austin.
DBA Consultant
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Feb 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

133 posts views Thread by jonathan | last post: by
2 posts views Thread by James Alexander Starritt | last post: by
5 posts views Thread by M. Savas Zorlu | last post: by
reply views Thread by exclaim | last post: by
reply views Thread by Gosth in the shell | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.