473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 9263
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

133
by: jonathan | last post by:
hey all, I realize that this question might pop up from time to time, but I haven't seen it a while and things might of changed, so - Right now (July 2004) how does mysql stand up in...
3
by: Leader | last post by:
Hi All, I am facing a problem with a sql what i used in MS Access but its not returning the same result in MS Sql Server 2000. Here i am giving the sql: SELECT TOP 3 format( MY_DATE, "dddd mm,...
2
by: James Alexander Starritt | last post by:
I also posted similarly in mailing.database.mysql I have created a rather large (60 table database) website dealio in PHP that works with MS SQL Server, Oracle, MySQL and presumably any other...
5
by: M. Savas Zorlu | last post by:
Hi, I just decided to leave Mssql and start using Mysql. I am having some problems with my queries; is there anyone here who has a knowledge of query syntax in Mysql? If so, I need some help...
0
by: exclaim | last post by:
Apologies if this is not the right forum. I have an application written originally to work with MySQL which now has to be extended to work with MSSQL also. I have modified all my database calls...
0
by: Gosth in the shell | last post by:
Hi there, i need some help I got a software to backend is MSSQL 2005, but a provider software requires an UPDATE on his table with MySQL 5.0.56a backend, so i made the next: download and...
1
by: nmailey | last post by:
Hi all. I'm having to convert a database over from MySQL to MSSQL 2000. The problem I'm encountering is that there's a password field that is using ENCODE and DECODE to set and retreive the...
0
by: johnyjj2 | last post by:
Hello! I've got web application written in MSSQL and I need to run it on server. But on the server I've go MySQL (not MSSQL), PHP, KFWS. Do I have to install MSSQL and have both MySQL and MSSQL?...
1
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.