[Previous] [Contents] [Next]


Date and time functions


Table 3-5 shows sample uses of selected time and date functions available in MySQL. The date_add( ) function can be used to add and subtract times and dates; more details can be found in Section 7.4.11 of the manual.html file distributed with MySQL.

Table 3-5. Using the date and time functions
Statement Output
SELECT dayofweek('2000-05-03');

3

SELECT dayname('2000-05-03');

Wednesday

SELECT monthname('2000-05-03');

May

SELECT week('2000-05-03');

18

SELECT date_add("2000-05-03", INTERVAL 1 DAY);

2000-05-04

SELECT curdate(  );

2002-01-01

SELECT curtime(  );

11:27:20

SELECT now(  );

2002-01-01 11:27:20


[Previous] [Contents] [Next]