If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
DAY() function , pass की हुई date के according integer value return करता है जो month के day को represent करता है। normal syntax कुछ इस तरह से होता है -
DAY(date_value);
DAY()
function में आप कोई भी date / datetime या कोई भी ऐसी value pass कर सकते हैं , जो date को represent करती हो।
SELECT DAY('2023-01-15');
Output
+-------------------+ | DAY('2023-01-15') | +-------------------+ | 15 | +-------------------+
ध्यान रहे अगर आप DAY() function में '0000-00-00' pass करेंगे तो आपको 0 ही मिलेगा और NULL pass करेंगे तो NULL मिलेगा।
For Example
SELECT DAY('0000-00-00'), DAY(NULL);
Output
+-------------------+-----------+ | DAY('0000-00-00') | DAY(NULL) | +-------------------+-----------+ | 15 | NULL | +-------------------+-----------+
MySQL में DAYOFMONTH() और DAY() दोनों ही function एक दूसरे के synonym हैं और same value return करते हैं।
अब कुछ examples देख लेते हैं , जिससे आपको और अच्छे से समझ आ जाये। Suppose, हमारे पास users
name की एक table है , जिसमे कुछ इस तरह से records available हैं।
+------------+---------------------+ | name | created_at | +------------+---------------------+ | Tom Cruise | 2023-02-09 13:07:31 | | John Quill | 2023-02-22 12:07:37 | | Wick | 2023-02-08 08:49:42 | | Rohan | 2023-01-08 08:49:42 | +------------+---------------------+
मुझे सिर्फ 8 तारीख के सभी records fetch करने हैं , तो उसके लिए कुछ इस तरह से query होगी -
SELECT name , created_at FROM users WHERE DAY(created_at)=8;
Output
+------------+---------------------+ | name | created_at | +------------+---------------------+ | Wick | 2023-02-08 08:49:42 | | Rohan | 2023-01-08 08:49:42 | +------------+---------------------+
हालाँकि आप अपनी need के according month या कोई दूसरी condition भी साथ में apply सकते हैं।
Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.
Get connected with me. :) LinkedIn Twitter Instagram Facebook