Working with dates (1 Viewer)

rinova

Registered User.
Local time
Today, 00:46
Joined
Aug 27, 2012
Messages
74
Hello Everyone,

I need help. I have a table with dates and other info and I'm trying to create a query that will show the date just before the most current date.

Example:
Code:
PS_Date            Status
12/1/2017             E
10/1/2017             I
12/1/2016             E
6/1/2015              I

The result should be:
Code:
PS_Date            Status
10/1/2017             I

Hope I provided enough info for someone to help.

Thank you in advance.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:46
Joined
Aug 30, 2003
Messages
36,118
SELECT TOP 1 *
FROM TableName
WHERE PS_Date <= Date()
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:46
Joined
May 7, 2009
Messages
19,169
SELECT TOP 1 PS_DATE, Status FROM yourTableName WHERE PS_DATE < (SELECT MAX(PS_DATE) FROM yourTableName) ORDER BY PS_DATE DESC;
 

Users who are viewing this thread

Top Bottom