Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

EXNO: 4(C)

DATE FUNCTION

AIM:
TO CREATE A PROGRAM USING DATE FUNCTION.
QURIES:
mysql> select adddate('2011-09-15',interval 5 day)as requried_date;
+---------------+
| requried_date |
+---------------+
| 2011-09-20
|
+---------------+
1 row in set (0.08 sec)
mysql> select adddate('2011-09-15',5);
+-------------------------+
| adddate('2011-09-15',5) |
+-------------------------+
| 2011-09-20
|
+-------------------------+
1 row in set (0.00 sec)
mysql> select last_day('2011-08-02');
+------------------------+
| last_day('2011-08-02') |
+------------------------+
| 2011-08-31
|
+------------------------+
1 row in set (0.08 sec)
mysql> select str_to_date('22,09,01',%d,%m,%y);
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that
corresponds to your MySQL server version for the right syntax to use near
'%d,%m
,%y)' at line 1
mysql> select str_to_date('22-09-01',%d,%m,%y);
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that
corresponds to your MySQL server version for the right syntax to use near
'%d,%m
,%y)' at line 1
mysql> select str_to_date('22-09-01','%d,%m,%y');
+------------------------------------+
| str_to_date('22-09-01','%d,%m,%y') |
+------------------------------------+
| NULL
|
+------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> select str_to_date('22,09,01','%d,%m,%y');

+------------------------------------+
| str_to_date('22,09,01','%d,%m,%y') |
+------------------------------------+
| 2001-09-22
|
+------------------------------------+
1 row in set (0.00 sec)
mysql> select sysdate();
+---------------------+
| sysdate()
|
+---------------------+
| 2011-11-20 22:59:05 |
+---------------------+
1 row in set (0.06 sec)
mysql> select greatest('20-aug-11','20-aug-12');
+-----------------------------------+
| greatest('20-aug-11','20-aug-12') |
+-----------------------------------+
| 20-aug-12
|
+-----------------------------------+
1 row in set (0.00 sec)
mysql> select least('20-aug-11','20-aug-12');
+--------------------------------+
| least('20-aug-11','20-aug-12') |
+--------------------------------+
| 20-aug-11
|
+--------------------------------+
1 row in set (0.00 sec)
RESULT :
THE ABOVE PROGRAM ARE CREATED AND EXECUTED SUCCESSFULLY.

You might also like