SELECT *
FROM table
WHERE DateCol = (SELECT MAX(DateCol) FROM Table)


HTH

--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA

-----Original Message-----
From: Bryan F. Hogan [mailto:[EMAIL PROTECTED]
Sent: Monday, January 05, 2004 10:10 AM
To: CF-Talk
Subject: RE: SQL: Selecting Max Date Entries

What I want to do is something like below.

select *
from table
where month(postdatetime)=max(month(postdatetime)) and
year(postdatetime)=max(year(postdatetime))

I want the current months entries. But if there is no entries I want it
to display the previous months entries. I only want it to display 1
months worth of entries.

-----Original Message-----
From: MILAN MUSHRAN [mailto:[EMAIL PROTECTED]
Sent: Monday, January 05, 2004 1:06 PM
To: CF-Talk
Subject: RE: SQL: Selecting Max Date Entries

If you are trying to get the highest date value in the database -
use this query:

SELECT max(DateColumnName)
FROM TableName

But, If you are trying to get the highest date value in the database for

every year -
use this query:

SELECT max(DateColumnName)
FROM TableName
GROUP BY DatePart('yyyy',DateColumnName)
   _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to