473,569 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9285
>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**********@gm ail.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
8922
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 comparison to oracle? We are seriously considering migrating our multi-processor oracle system to mysql to save on licensing costs, and would need several...
3
34901
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, yyyy" ) FROM MY_TAB WHERE MY_ID=1 The above sql in ACCESS return me the date in below format in one column:
2
3075
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 data base I add to the wrapper functions that I created. All the development was done in Oracle, but now its time to create that large datastructure...
5
1801
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 with couple of queries.
0
1494
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 to use the PEAR MDB2 methods rather than mysqli. Everything still works fine with MySQL, but I have an odd problem when I test against MSSQL. Any...
0
1767
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 install ODBC MySQL 3.51 configuring system DSN add a linked server on MSSQL 2005
1
4146
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 password, and I'm unable to find an equivalent to this in MSSQL. So, my question is: Is there an equivalent to ENCODE/DECODE in MSSQL or is there a...
0
1558
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? Won't it make any problems? Can I use 4CRM SQL 5.1.4 or EMS MS SQL Manager Lite 1.8 to run my MSSQL web application? How to run it? (In the web...
1
9558
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 things (stored procedures, functions).. we have to manually edit. That time, we face some interesting challenges.. I failed to document all of them,...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.