camper12
asked on
sql end of month
Hi,
I have a list of dates for example,
1/1/2002
1/2/2002....
31/1/2002..
1/2/2003
2/2/2003..
2/27/2003
I want to create a temp table and select only those dates that are end of month for each year. I could have used
select DATEADD(DAY,-1, '3/1/2003')) but this would have returned me 2/28/2003 but I need to get 2/27/2003
How can i do this in sql. Can i use loop in sql?
Thanks
I have a list of dates for example,
1/1/2002
1/2/2002....
31/1/2002..
1/2/2003
2/2/2003..
2/27/2003
I want to create a temp table and select only those dates that are end of month for each year. I could have used
select DATEADD(DAY,-1, '3/1/2003')) but this would have returned me 2/28/2003 but I need to get 2/27/2003
How can i do this in sql. Can i use loop in sql?
Thanks
31/1/2002 is certainly a typo ...
It looks like you need the last row found for each month. Or is it only the date itself?
It looks like you need the last row found for each month. Or is it only the date itself?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I am just curious...
Does the solution work for December?
Does the solution work for December?
why don't you try, substitute any date in december in the [datefield] and found out the result for yourself.
trying is one way of learning.
trying is one way of learning.
Open in new window