Need help with SQL, dates and surrounding dates. (1 Viewer)

charliemopps

Registered User.
Local time
Yesterday, 23:36
Joined
Feb 24, 2009
Messages
40
I have a list of stuff that I have to querry on a Linux based server. Each file is named by date, and the stuff I want could be on the date listed in my report or on either the prior or 2 days after due to GMT and other wishy washy stuff.

So what I want is to have a list of dates + 1day prior to the first date, and the 2 dates after the last date. Also if there is a break in the dates I need the 2 dates after both the last dates.

Example, my table has the following dates

4/20/2010
4/21/2010
4/22/2010
5/15/2010
4/16/2010

I'd like the output to be:
4/19/2010
4/20/2010
4/21/2010
4/22/2010
4/23/2010
4/24/2010
5/14/2010
5/15/2010
4/16/2010
5/17/2010
5/18/2010

So I can then build my Grep command with that.

I have the SQL to sort and limit the dates for me but I don't know how to add the extra dates. Any ideas?

Code:
SELECT CDate(Int([Dateof])) AS Expr1
FROM Tbl_Reports
WHERE (((Tbl_Reports.Ticket)=0) AND ((Tbl_Reports.Dateof) Is Not Null))
GROUP BY CDate(Int([Dateof]))
ORDER BY CDate(Int([Dateof]));
 

khawar

AWF VIP
Local time
Today, 10:36
Joined
Oct 28, 2006
Messages
870
A quick sample to add extra dates is attached

I have just added one table with one field

Check data in the table first then open query "RequiredQuery"
 

Attachments

  • Add_Extra_Dates.zip
    8 KB · Views: 112
Last edited:

charliemopps

Registered User.
Local time
Yesterday, 23:36
Joined
Feb 24, 2009
Messages
40
That sort of works but I have multiple duplicate dates. Thats why I had the
CDate(Int([Dateof]))

How can I just show unique dates with your meathod? I tried substituting my formula but it didnt work
 

khawar

AWF VIP
Local time
Today, 10:36
Joined
Oct 28, 2006
Messages
870
Use another query and select distinct dates from first query
 

Users who are viewing this thread

Top Bottom