Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Mysql Date Arithmetic 
 

Date Arithmetic is used to display the current date, interval in current date and time.

 

Mysql Date Arithmetic

                         

Date Arithmetic is used to display the current date, interval in current date and time.

Understand with Example

The Tutorial illustrate an example from 'Date Arithmetic' in Mysql. To grasp this example, we  run the select now ( ) query that return you the current date and time.

SYNTAX:-date + INTERVAL expression unit

Query:-

For current date and time

mysql> Select now();

Output:-

+---------------------+
| now() |
+---------------------+
| 2008-12-19 14:34:02 |
+---------------------+
1 row in set (0.02 sec)

Query:-

The Query returns you the 2 days and time before the current time 

For subtracting 2 days from current date.

mysql> select now()- interval 2 day;

Output:-

+-----------------------+
| now()- interval 2 day |
+-----------------------+
| 2008-12-17 14:34:47 |
+-----------------------+
1 row in set (0.02 sec)

Query:-

The Query returns you the 5 minute before the current minute.

For current date+time minus 5 minutes

mysql> select now()- interval 5 minute;

Output:-

+--------------------------+
| now()- interval 5 minute |
+--------------------------+
| 2008-12-19 14:35:13 |
+--------------------------+
1 row in set (0.00 sec)

Query:-

The Query adds 5 days to the current date.

For Adding 5 days from current date.

mysql> select now()+ interval 5 day;

Output:-

+-----------------------+
| now()+ interval 5 day |
+-----------------------+
| 2008-12-24 14:45:06 |
+-----------------------+
1 row in set (0.00 sec)

                         

» View all related tutorials
Related Tags: sql mysql c orm form time make format display value this create for ie example values exam e it mms

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.