SELECT *
FROM table
WHERE month(DateCol) = (SELECT month(MAX(DateCol)) FROM Table) AND
year(DateCol) = (SELECT year(MAX(DateCol)) FROM Table)
Not sure of the syntax on this one. The month and year functions may need
to be outside the imbedded select statement, instead of incorporated into
it?
WHERE month(DateCol) = month((SELECT MAX(DateCol) FROM Table)) AND
year(DateCol) = year((SELECT MAX(DateCol) FROM Table))
I would think one of those forms should work.
HTH.
--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA
-----Original Message-----
From: Ian Skinner
Sent: Monday, January 05, 2004 10:21 AM
To: CF-Talk
Subject: RE: SQL: Selecting Max Date Entries
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]

