Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / June 2009



Tip: Looking for answers? Try searching our database.

Last Date of Month in SQL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Webbiz - 26 Jun 2009 06:35 GMT
I have a table called MONTHLY where one of the fields is a date field
called Date.

This field holds the date of the last weekday of each month.

When I create a recordset from this table, I would like to get the
dates to convert to LAST DATE of each month.

For example, if the date happens to be:

1/30/2009 'last weekday of the month

I'd like it to be in my recordset as 1/31/2009

2/27/2009 'last weekday of the month

I'd like it to be 2/28/2009

3/31/2009 to 3/31/2009 'no change, last day

4/30/2009 to 4/30/2009 'no change, last day

5/29/2009 to 5/31/2009

6/30/2009 to 6/30/2009 'no change, last day

7/31/2009 to 7/31/2009 'no change

8/31/2009 to 8/31/2009 'no change

I think you can see what I'm trying to do. All the dates in the
resulting recordset need to be the LAST DAY OF EACH MONTH, not the
last weekday of the month as it is currently in the table.

How would I write a SQL statement to do this?

Thanks.

Webbiz
Webbiz - 26 Jun 2009 15:17 GMT
Found the solution:

SELECT date(Date,'start of month','+1 month','-1 day') as Date

>I have a table called MONTHLY where one of the fields is a date field
>called Date.
[quoted text clipped - 35 lines]
>
>Webbiz
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.