0% found this document useful (0 votes)
16 views

Practical 19 - MySQL - Date Time Functions

This document discusses MySQL date and time functions like now(), curdate(), date(), month(), day(), weekday(), dayname(), and dayofyear(). Examples are provided for each function showing how to use them and return values.

Uploaded by

Himanshu Daksh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Practical 19 - MySQL - Date Time Functions

This document discusses MySQL date and time functions like now(), curdate(), date(), month(), day(), weekday(), dayname(), and dayofyear(). Examples are provided for each function showing how to use them and return values.

Uploaded by

Himanshu Daksh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Practical 19

Date & Time Functions


Introduction -
now() -
curdate() -
date() -
month() -
day() -
weekday() -
dayname() -
dayofyear() -

mysql> select now();

+---------------------+

| now() |

+---------------------+

| 2021-01-27 11:55:16 |

+---------------------+

1 row in set (0.00 sec)

mysql> select curdate();

+------------+

| curdate() |

+------------+

| 2021-01-27 |

+------------+

1 row in set (0.00 sec)


mysql> select date('2021-01-27 11:54:56');

+-----------------------------+

| date('2021-01-27 11:54:56') |

+-----------------------------+

| 2021-01-27 |

+-----------------------------+

1 row in set (0.00 sec)

mysql> select month('2021-07-02');

+---------------------+

| month('2021-07-02') |

+---------------------+

| 7 |

+---------------------+

1 row in set (0.00 sec)

mysql> select day('2021-07-02');

+-------------------+

| day('2021-07-02') |

+-------------------+

| 2 |

+-------------------+

1 row in set (0.00 sec)

mysql> select weekday('2021-07-02');

+-----------------------+

| weekday('2021-07-02') |

+-----------------------+

| 4 |
+-----------------------+

1 row in set (0.00 sec)

mysql> select weekday('2021-01-27');

+-----------------------+

| weekday('2021-01-27') |

+-----------------------+

| 2 |

+-----------------------+

1 row in set (0.00 sec)

mysql> select dayname('2021-01-27');

+-----------------------+

| dayname('2021-01-27') |

+-----------------------+

| Wednesday |

+-----------------------+

1 row in set (0.00 sec)

mysql> select dayname('2021-02-27');

+-----------------------+

| dayname('2021-02-27') |

+-----------------------+

| Saturday |

+-----------------------+

1 row in set (0.00 sec)

mysql> select dayofyear('2021-02-27');

+-------------------------+

| dayofyear('2021-02-27') |
+-------------------------+

| 58 |

+-------------------------+

1 row in set (0.00 sec)

You might also like