MySQL YEAR Function | YEAR In MySQL In Hindi

📔 : MySQL 🔗

YEAR() function एक date as an argument लेता है और date की year value return करता है।

Syntax

YEAR(date_value);

YEAR() function 1000 से 9999 की range में year value return करता है , अगर date है 0 तो आपको 0 ही मिलेगा।

MySQL YEAR Example

SELECT YEAR('2023-03-02');

Output

+--------------------+
| YEAR('2023-03-02') |
+--------------------+
|               2023 |
+--------------------+

ध्यान रहे अगर date value NULL pass होगी तो return में भी NULL ही मिलेगा।

SELECT YEAR(NULL);

Output

+------------+
| YEAR(NULL) |
+------------+
|       NULL |
+------------+

MySQL Get Current Year

Current year , get करने के लिए NOW() function को directly pass कर सकते हैं।

For Example

SELECT YEAR(NOW());

Output

+-------------+
| YEAR(NOW()) |
+-------------+
|        2023 |
+-------------+

जैसा कि अपने ऊपर पढ़ा कि अगर value में 0 या '0000-00-00' pass किया तो 0 ही मिलेगा।

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers