Home >>MySQL Tutorial >MySQL Predefined Function
There are several predefined library function defined in MySQL library by the help of these functions the performance increases and length of code decreases excessively as we need not to write these complex functions. these predefined functions increases the code re-usability.
Below are the mysql functions that are related to date
sysdate()
current_data()
now()
current_timestamp()
curdate()
datediff()
If we need to find out the difference between two dates the we can use the datediff() function also suppose if we want to find the current system date the we can use sysdate() function. several functions of these kind are available in Mysql library.Function | What it Does |
---|---|
sysdate( ) | it returns the current date of the system. |
SELECT sysdate() from empinfo(table name)
Output : 2013-05-04 16:36:58 |
|
current_data( ) | it also returns the current date of the system |
SELECT current_date() from empinfo
Output : 2013-05-04 |
|
now( ) | it returns current date, current time with fraction of seconds and the time zone fom GMT. |
SELECT now() from empinfo |
|
current_timestamp( ) | it returns current date, current time with fraction of seconds and the time zone fom GMT |
SELECT current_timestamp() from empinfo
Output : 2013-05-04 16:46:54 |
|
curdate( ) | it returns current date, current time with fraction of seconds and the time zone fom GMT |
SELECT CURDATE() FROM from empinfo
Output : 2013-05-04 |
|
datediff( ) | it Returns the number of days between two dates. |
SELECT DATEDIFF("2013-02-16","2013-02-20") FROM empinfo
Output : 4 |