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 ! 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