Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
 
 


 

Mysql Date Format codes

                         

The Tutorial illustrate an example from 'Mysql date format'. In this example we let you know ,how to display the current date and time in the system. The now ( ) as Date is used to display the current date, month, year and time in (hh:mm:sec).

Query:-

mysql> select now() as Date;

Output:-

+---------------------+
| Date |
+---------------------+
| 2008-12-20 11:24:28 |
+---------------------+
1 row in set (0.00 sec)

Query:-

The given Query return the current date, month and year. 

The syntax (now( ),'%e-%m-%y')  return you the date format in dd-mm-yy.

mysql> select date_format(now(),'%e-%m-%y')as Date;

Output:-

+----------+
| Date |
+----------+
| 20-12-08 |
+----------+
1 row in set (0.00 sec)

Query:-

The date_format(now( ),'%W') return you the week of the day.

mysql> select date_format(now(),'%W')as Day;

Output:-

+----------+
| Day |
+----------+
| Saturday |
+----------+
1 row in set (0.00 sec)

Query:-

The below Query (now( ),'%w') return the weekday number . 

mysql> select date_format(now(),'%w')as DayofWeek;

Output:-

+-----------+
| DayofWeek |
+-----------+
| 6 |
+-----------+
1 row in set (0.00 sec)

Query:-

The below Query format(now(),'%e') return you the day of the month.

mysql> select date_format(now(),'%e')as Date;

Output:-

+------+
| Date |
+------+
| 20 |
+------+
1 row in set (0.00 sec)

Query:-

The given below Query (now( ),'%M') show you the month of the year.

mysql> select date_format(now(),'%M')as Month;

Output:-

+----------+
| Month |
+----------+
| December |
+----------+
1 row in set (0.00 sec)

Query:-

The date_format(now( ),'%m') return you the month number of the year.

mysql> select date_format(now(),'%m')as Month;

Output:-

+-------+
| Month |
+-------+
| 12 |
+-------+
1 row in set (0.00 sec)

Query:-

The date_format(now( ),'%W %e%M%Y') return you the current week, day, month and year.

mysql> select date_format(now(),'%W %e %M %Y')as Date;

Output:-

+---------------------------+
| Date |
+---------------------------+
| Saturday 20 December 2008 |
+---------------------------+
1 row in set (0.00 sec)

                         

» View all related tutorials
Related Tags: sql mysql c table date data io view order vi range this create tab ie example to learn exam fetch

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.