Home >> FAQs/Tutorials >> MySQL Tutorials

MySQL Tutorial - Date and Time Intervals

By: FYIcenter.com

(Continued from previous topic...)

What Are Date and Time Intervals?

A date and time interval is special value to be used to increment or decrement a date or a time at a given date or time unit. A data and time interval should be expression in the format of "INTERVAL expression unit", where "unit" and "expression" should follow these rules:

unit                 expression value format

MICROSECOND          MICROSECONDS 
SECOND               SECONDS 
MINUTE               MINUTES 
HOUR                 HOURS 
DAY                  DAYS 
WEEK                 WEEKS 
MONTH                MONTHS 
QUARTER              QUARTERS 
YEAR                 YEARS 
SECOND_MICROSECOND   'SECONDS.MICROSECONDS' 
MINUTE_MICROSECOND   'MINUTES.MICROSECONDS' 
MINUTE_SECOND        'MINUTES:SECONDS' 
HOUR_MICROSECOND     'HOURS.MICROSECONDS' 
HOUR_SECOND          'HOURS:MINUTES:SECONDS' 
HOUR_MINUTE          'HOURS:MINUTES' 
DAY_MICROSECOND      'DAYS.MICROSECONDS' 
DAY_SECOND           'DAYS HOURS:MINUTES:SECONDS' 
DAY_MINUTE           'DAYS HOURS:MINUTES' 
DAY_HOUR             'DAYS HOURS' 
YEAR_MONTH           'YEARS-MONTHS' 

(Continued on next topic...)

  1. What Are Date and Time Data Types?
  2. How To Write Date and Time Literals?
  3. How To Enter Microseconds in SQL Statements?
  4. How To Convert Dates to Character Strings?
  5. How To Convert Character Strings to Dates?
  6. What Are Date and Time Intervals?
  7. How To Increment Dates by 1?
  8. How To Decrement Dates by 1?
  9. How To Calculate the Difference between Two Dates?
  10. How To Calculate the Difference between Two Time Values?
  11. How To Present a Past Time in Hours, Minutes and Seconds?
  12. How To Extract a Unit Value from a Date and Time?
  13. What Are Date and Time Functions?
  14. What Is TIMESTAMP Data Type?
  15. How Many Ways to Get the Current Time?

MySQL Tutorials:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...