SELECT Dateadd(month, Datediff(month, 0, Getdate()), 0),
'First Day of Current Month'
Can anyone tell me how this query works to get the first day of current month?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Firstly
Datediff(month, 0, Getdate()) will give will give total months from 1900
and from 1900 you add the months returned by the above months, so you will get month’s first date
Eg : if we take present month then
Datediff(month, 0, Getdate()) = 1349 months
and if you add 1349 months to the ‘1900/01/01’ you will get this months first date ‘2012/06/01’