By 25/02/2016 11 Comments

What Are Date Functions In MySQL?

  • There are some special built-in functions in SQL for handling the date and time in database.
  • These SQL functions define different operations for date and time.
  • The date data types of a table column can be set at the time of table creation in database.

Following Date Functions are available in MySQL:

Function Description
NOW() Represent current date and time
CURDATE() Represent current date
CURTIME() Represent current time
DATE() Extracts the date part of a date or date/time expression
EXTRACT() Represent a single part of a date/time
DATE_FORMAT() Displays date/time data in different formats


Date or time values can be inserted in MySQL database by using the following date data types:

Data type Accept format
DATE YYYY-MM-DD
DATETIME YYYY-MM-DD HH:MI:SS
TIMESTAMP YYYY-MM-DD HH:MI:SS
YEAR YYYY or YY

Example

SELECT p_name, price, p_date
FROM products
WHERE p_date = '2016-01-06';


Note:

  • In above example the SELECT statement selects only a product which is added on 2016-01-06.






Posted in: Sql

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .