![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I use 2-digit year value in MySQL DATEDIFF() function?
We can use 2-digit year value either in single date expression or in both date expressions used as argument/s in MySQL DATEDIFF() function.
For example, the query below is using 2-digit year value in first date expression and other is having 4-digit year value.
mysql> Select DATEDIFF('18-10-22','2017-10-22'); +-----------------------------------+ | DATEDIFF('18-10-22','2017-10-22') | +-----------------------------------+ | 365 | +-----------------------------------+ 1 row in set (0.00 sec)
And the query below is using 2-digit year value in both date expressions.
mysql> Select DATEDIFF('18-10-22','17-10-22'); +---------------------------------+ | DATEDIFF('18-10-22','17-10-22') | +---------------------------------+ | 365 | +---------------------------------+ 1 row in set (0.00 sec)
Advertisements