
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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)
- Related Articles
- How MySQL DATEDIFF() function works?
- How can we ignore the negative values return by MySQL DATEDIFF() function?
- How can I use another MySQL function/s with REPEAT() function?
- How MySQL use YEAR data type to store year value in a table?
- How can I use MySQL IN() function to compare row constructors?
- How can I use MySQL IF() function within SELECT statement?
- How can I use SPACE() function with MySQL WHERE clause?
- How can I use IFNULL() function at the place of COALESCE() function in MySQL?
- How can I use TIME_FORMAT() function to offload time/date values in MySQL?
- Get the correct century from 2-digit year date value - JavaScript?
- How can we use MySQL SUM() function?
- How can I use MySQL INTERVAL() function with a column of a table?
- How to use a function for default value in MySQL?
- How can I use a SELECT statement as an argument of MySQL IF() function?
- How can we use MySQL function STR_TO_DATE(Column, ‘%input_format’)?

Advertisements