string st = '01/2012' (MM/yyyy)
I want to get the data between 01/01/2012 and 31/01/2012
How to create a start date and end date according to month and year format?
For Example
st = 02/2012
Select * from table where dates between 01/02/2012 and 29/02/2012
How to make a query for adding start and end date of the month?
The following should give you the last day of the current month on sql-server-2000:
SELECT DATEADD(second,-1,DATEADD(month, DATEDIFF(month,0,GETDATE())+1,0))
To find the last day of the month for a given month try:
DECLARE @thisDate DATETIME
SET @thisDate = '06/27/2011'
SELECT DATEADD(second,-1,DATEADD(month, DATEDIFF(month,0,@thisDate)+1,0))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With