Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
write a query to get Endof of the month without using EOMONTH() function.


What I have tried:

dateadd(month,1+datediff(month,0,getdate()),-1)
Posted
Updated 30-Jul-19 19:52pm
Comments
MadMyche 30-Jul-19 22:43pm    
Why can't you use the EOMonth function?

1 solution

Think about it: you want a new date object with the same year and month, but the day set to 31, 30, 29, or 28.
The easiest way to do that is create a new date with the same year and month, but the day set to 1. Then add one month. Then subtract one day.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900