473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Selecting Dates for a Schedule - Assistance Please!

Hi there

I have a list of jobs scheduled in a MySQL table, with start dates and
end dates, like so:

SchedID | JobID | StartDate | EndDate |
----------------------------------------------
1 5 2006-05-08 2006-05-09
2 8 2006-05-10 2006-05-12
3 3 2006-05-01 2006-05-19
4 9 2006-05-09 2006-05-11
5 6 2006-05-14 2006-05-19
In my web application, I have a request to show scheduled jobs between
certain dates, usually in 1-week or 2-week views.

I thought this was super easy, but I've run into a problem:
How do I show jobs scheduled for the week of 2006-05-07 to 2006-05-13?

Originally, my query was something along the line of

"SELECT * FROM SchedJobs WHERE EndDate < 2006-05-13"
....or...
"SELECT * FROM SchedJobs WHERE StartDate BETWEEN '2006-05-07' AND '2006-
05-13'"

.... but of course, both queries will fail to include the job with SchedID
3 in the result, that starts on 2006-05-01 and ends on 2006-05-19, as it
begins before the requested start date, and ends after the requested end
date.

How can I get a list of job results for everything taking place within
two selected dates?

Much thanks in advance!

May 10 '06 #1
4 1553
Good Man wrote:
Hi there

I have a list of jobs scheduled in a MySQL table, with start dates and
end dates, like so:

SchedID | JobID | StartDate | EndDate |
----------------------------------------------
1 5 2006-05-08 2006-05-09
2 8 2006-05-10 2006-05-12
3 3 2006-05-01 2006-05-19
4 9 2006-05-09 2006-05-11
5 6 2006-05-14 2006-05-19
In my web application, I have a request to show scheduled jobs between
certain dates, usually in 1-week or 2-week views.

I thought this was super easy, but I've run into a problem:
How do I show jobs scheduled for the week of 2006-05-07 to 2006-05-13?

Originally, my query was something along the line of

"SELECT * FROM SchedJobs WHERE EndDate < 2006-05-13"
...or...
"SELECT * FROM SchedJobs WHERE StartDate BETWEEN '2006-05-07' AND
'2006- 05-13'"

... but of course, both queries will fail to include the job with
SchedID 3 in the result, that starts on 2006-05-01 and ends on
2006-05-19, as it begins before the requested start date, and ends
after the requested end date.

How can I get a list of job results for everything taking place within
two selected dates?

Much thanks in advance!


SELECT * FROM SchedJobs WHERE StartDate <= '2006-05-13' and EndDate >=
'2006-05-07'
May 10 '06 #2
"Paul Lautman" <pa**********@btinternet.com> wrote in news:4cc08cF14situU1
@individual.net:
Good Man wrote:
How can I get a list of job results for everything taking place within
two selected dates?

Much thanks in advance!


SELECT * FROM SchedJobs WHERE StartDate <= '2006-05-13' and EndDate >=
'2006-05-07'


Thanks very much Paul. Depressingly simple answer.
May 10 '06 #3
Good Man wrote:
"Paul Lautman" <pa**********@btinternet.com> wrote in
news:4cc08cF14situU1 @individual.net:
Good Man wrote:
How can I get a list of job results for everything taking place
within two selected dates?

Much thanks in advance!


SELECT * FROM SchedJobs WHERE StartDate <= '2006-05-13' and EndDate
>= '2006-05-07'


Thanks very much Paul. Depressingly simple answer.


Questions are always simple when you know the answers!

How are your scheduled jobs triggered and run?
May 10 '06 #4
"Paul Lautman" <pa**********@btinternet.com> wrote in news:4cc11vF154ch8U1
@individual.net:
Good Man wrote:
SELECT * FROM SchedJobs WHERE StartDate <= '2006-05-13' and EndDate
>= '2006-05-07'


Thanks very much Paul. Depressingly simple answer.


Questions are always simple when you know the answers!

How are your scheduled jobs triggered and run?


it's more of a display-only thing; ie: a Gantt chart is being created on
the fly that displays scheduling info & other details about jobs during
requested dates....

thanks again
May 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: netsurfer | last post by:
Hi: Have a question on making the date automatically filled in by what the user enters in by the date at the top. The date entered at the top would most likely be on a Wednesday then I need...
1
by: bigfella | last post by:
Hi Everyone, I am using the following code (many thanks for the code folks BTW) to generate 3 schedules in three tables one is a schedule with 7 day intervals and two are daily schedules. The...
2
by: Kenny G | last post by:
I would like some assistance on writing a procedure. I have a StartDate and an EndDate. If the EndDate is less than the StartDate then I need to undo the input in the EndDate, let the user know...
3
by: Michael Curtis | last post by:
This is kicking my @#$%. I have been asked to do a performance report for our vendors. I need to compare and count dates. 1. Is called which is in a table named JOB DATES 2. Is called which...
1
by: vunderusaf | last post by:
I have a listbox on a form that is selecting using named FinalQuery: SELECT ., ., . FROM FinalQuery; Now I have a text field with a date on this form and I'd like to use that date as the...
1
by: josecruz | last post by:
I have to create a summary report that will provide counts and # average of days for multiple "Status" by entering different dates for every criteria. I have created several queries that calculates...
4
by: J | last post by:
I am editing a pre-existing view. This view is already bringing data from 40+ tables so I am to modify it without screwing with anything else that is already in there. I need to (left) join it...
4
by: Ruben | last post by:
Hi, I have a continuous form that provides a listing of various instruments that are serviced on a monthly to annual basis, with general info about the instrument, last and next service dates,...
2
by: BeckR | last post by:
Hello: Thanks for reading my post. I am trying to generate Athletic League schedules using Access 2003 and Windows XP PRO. I am using DateSerial in a text box to print the game dates on the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.