Updating Last Day of Month

G

Guest

I have a table that I want to update the rows that have the day that is the
most close to the last day of the month. For example

Row 1 1/15/04
Row 2 1/27/04 Would be updated
Row 3 2/14/04 Would be updated
Row 4 3/2/04
Row 5 3/8/04
Row 6 3/24/04 Would be updated.
 
J

John Viescas

One of many possible solutions:

UPDATE MyTable
SET ...
WHERE MyTable.RecordDate =
(SELECT Max(RecordDate)
FROM MyTable As T2
WHERE Year(T2.RecordDate) = Year(MyTable.RecordDate)
AND Month(T2.RecordDate) = Month(MyTable.RecordDate))

--
John Viescas, author
"Building Microsoft Access Applications" (Coming Soon!)
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top