MySQL CURDATE Function In Hindi | CURDATE In MySQL In Hindi

📔 : MySQL 🔗

MySQL में CURDATE() function , YYYY-MM-DD की form में current date return करता है। हालाँकि YYYY-MM-DD format आपको एक string की तरह मिलता है।

MySQL CURDATE Example

SELECT CURDATE();

Output

+------------+
| CURDATE()  |
+------------+
| 2023-03-15 |
+------------+

और CURDATE() को numeric context में use करने के लिए कुछ इस तरह से +0 add कर दिया जाता है।

SELECT CURDATE()+0;

Output

+-------------+
| CURDATE()+0 |
+-------------+
|    20230315 |
+-------------+
Change Format

हालाँकि आप need के according DATE_FORMAT() function की help से date का format change भी कर सकते हैं।

Example

SELECT DATE_FORMAT(CURDATE(), '%D-%M-%Y'), DATE_FORMAT(CURDATE(), '%M-%D-%Y'), DATE_FORMAT(CURDATE(), '%d-%m-%y');

Output

+------------------------------------+------------------------------------+------------------------------------+
| DATE_FORMAT(CURDATE(), '%D-%M-%Y') | DATE_FORMAT(CURDATE(), '%M-%D-%Y') | DATE_FORMAT(CURDATE(), '%d-%m-%y') |
+------------------------------------+------------------------------------+------------------------------------+
| 15th-March-2023                    | March-15th-2023                    | 15-03-23                           |
+------------------------------------+------------------------------------+------------------------------------+

MySQL CURRENT_DATE

CURRENT_DATE और CURRENT_DATE() भी CURDATE() के synonyms ही हैं मतलब ये तीनो आपको same value return करेंगे।

For Example

SELECT CURRENT_DATE(), CURRENT_DATE, CURDATE();

Output

+----------------+--------------+------------+
| CURRENT_DATE() | CURRENT_DATE | CURDATE()  |
+----------------+--------------+------------+
| 2023-03-15     | 2023-03-15   | 2023-03-15 |
+----------------+--------------+------------+

MySQL CURDATE vs NOW

NOW() function से भी आप current date get कर सकते हैं लेकिन यह आपको current date और time दोनों ही return करता है , जबकि CURDATE() से आपको current date मिलती है।

Example

SELECT CURRENT_DATE(), NOW();

Output

+----------------+---------------------+
| CURRENT_DATE() | NOW()               |
+----------------+---------------------+
| 2023-03-15     | 2023-03-15 06:22:55 |
+----------------+---------------------+

लेकिन आप अपनी need के according date या time को format भी कर सकते हैं।

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