Home arrow MySQL arrow Date Arithmetic With MySQL

Date Arithmetic With MySQL

When dealing with date and time values, one of the more common (and complex) tasks involves performing addition and subtraction operations on these values. However, with MySQL's powerful date and time API taking care of all the minor adjustments for you, manipulating date and time data is no longer the tedious and time-consuming process it used to be. Find out why, inside.

TABLE OF CONTENTS:
  1. Date Arithmetic With MySQL
  2. When Two And Two Don't Make Four
  3. Counting Down
  4. The Number Game
  5. Artificial Intelligence
  6. A Short Interval
  7. Lather, Rinse, Repeat
  8. Code Poet
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 35
July 03, 2003

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

If you're familiar with MySQL, one of the planet's most popular open-source RDBMS, you already know that it supports a wide variety of data types for numbers, strings and dates. These data types perform two very important
functions: they enforce consistency on the data in a MySQL table (ensuring, for example, that numeric columns do not contain character data) and they optimize the space (bytes) required to store each type of data.

Now, MySQL comes with almost different data types, including types for integers, floating-point numbers, strings, date and time values, and data collections. One of the larger categories among these is the one containing date and time types, primarily because MySQL includes date and time types to meet almost every need you could think of. For example, there's the TIMESTAMP type to store timestamps, the DATE and TIME types to store just dates or times, the hybrid DATETIME type to store both, and the YEAR type to store the year component of a date.

Of course, data types, by themselves are only one piece of the puzzle; in order to do something with them, you need functions. And MySQL scores high points there as well, providing over 40 built-in functions to process and manipulate date and time values. The MySQL date and time API includes functions to extract different components of a timestamp, to format a timestamp in a variety of different ways, to obtain the current date and time, to convert between different date and time formats, and much, much more.

Sadly, this article isn't going to examine the complete date and time API in MySQL; instead, it's going to focus on a very small subset of this API, the functions related to performing date and time arithmetic. Flip the page, and let's get started.



 
 
>>> More MySQL Articles          >>> More By icarus, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

MYSQL ARTICLES

- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: