Showing posts with label extract function. Show all posts
Showing posts with label extract function. Show all posts

Monday, 16 July 2012

Mysql extract (date) Function

extract() function can be used to extracting date value from any date.
SELECT EXTRACT(YEAR FROM '2009-07-02');
o/p: 2009
SELECT EXTRACT(MONTH FROM '2009-07-02');
o/p: 7
SELECT EXTRACT(DAY FROM '2009-07-02');
o/p: 2
Point to be Noted:
SELECT EXTRACT(MONTH FROM '2009-13-02');
Above Code will o/p NULL, because month exceeded to 12.