473,513 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with dates

[sorry about the earlier post. accidently hit enter]

I'm working on a website for some firefighters that want to be able to
sign-up for overtime and I need some help figuring out a date related
problem.

Here's the scenario:

Four groups of firefighters (group1, group2, group3, group4). Each
group works a 24 hr shift. So group1 works April 1, group2 works April
2, group3 works April 3, group4 works April 4, group 1 works April 5,
etc. It just keeps rolling like this forever into next year, etc.

I need to come up with a methodology for the following:

If given a date, find out what group is working on that date.

Has anyone dealt with a problem like this before? Obviously I'll need
to have a starting date where group1 is associated with a starting
date. Fortunately there are no surprises. Groups work in order
(1,2,3,4,1,2,3,4,1,2,...) and dates go in order and there are
absolutely no special exceptions for holidays and anything else.

Thanks in advance for any clues.

Kevin

Mar 31 '07 #1
2 1125
Four groups of firefighters (group1, group2, group3, group4). Each
group works a 24 hr shift. So group1 works April 1, group2 works April
2, group3 works April 3, group4 works April 4, group 1 works April 5,
etc. It just keeps rolling like this forever into next year, etc.

I need to come up with a methodology for the following:

If given a date, find out what group is working on that date.
Hello,

You can use method datetime.date.toordinal() :

from datetime import date
start = date(2007,4,1) # Arpil 1, 2007

def group(_date):
return (date.toordinal(_date)-date.toordinal(start)) % 4

print group(date(2007,4,15))

Regards,
Pierre

Mar 31 '07 #2
On Apr 1, 7:51 am, "Pierre Quentel" <quentel.pie...@wanadoo.frwrote:
Four groups of firefighters (group1, group2, group3, group4). Each
group works a 24 hr shift. So group1 works April 1, group2 works April
2, group3 works April 3, group4 works April 4, group 1 works April 5,
etc. It just keeps rolling like this forever into next year, etc.
I need to come up with a methodology for the following:
If given a date, find out what group is working on that date.

Hello,

You can use method datetime.date.toordinal() :

from datetime import date
start = date(2007,4,1) # Arpil 1, 2007

def group(_date):
return (date.toordinal(_date)-date.toordinal(start)) % 4
.... whose possible outcomes are (0, 1, 2, 3) whereas the groups are
numbered 1 to 4. However I'm sure the OP can make the necessary
adjustment :-)
>
print group(date(2007,4,15))

Regards,
Pierre

Apr 1 '07 #3

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

Similar topics

5
3472
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
2
3499
by: Ian DeRock | last post by:
I'm fairly new to XML. As I can see it, XML is a way to organize data like in a table in a RDB, or the RDB itself. I have used XML in application data, but did not design the actual XML. I...
8
3169
by: Shlomi Schwartz | last post by:
Hi all, Why do I get the folowing date when creating it like so: var d = new Date(2003,9,2); Wed Oct 1 23:00:00 UTC+0200 2003 Isent it soposed to be:
6
2415
by: paii | last post by:
I have a table that stores job milestone dates. The 2 milestones I am interested in are "Ship Date" TypeID 1 and "Revised Ship Date" TypeID 18. All jobs have TypeID 1 only some jobs have TypeID 18....
5
2372
by: Alicia | last post by:
Yes, but will that skip a week and group by the date for me? I basically wanted something that would do a count of the dates, then group them by their week name.. BEFORE: Resource Date ...
8
10394
by: Lyn | last post by:
I am trying to get my head around the concept of default, special or empty values that appear in Access VBA, depending on data type. The Access Help is not much (help), and the manual that I have...
0
1893
by: Brian Henry | last post by:
Ok I've never implemented a snap location before so I dont really know what im doing wrong here... anyways, I am making a custom slider control that takes dates as its values instead of integers......
2
1328
by: mario | last post by:
Hi, I have verry big problem. I must write function using dates. This is a problem: I have some dates for example: 2006-01-01, 2006-02-05, 2006-10-15 etc. then some times: 20sec, 50sec, 45sec...
4
1703
by: Steve Chow | last post by:
I was wondering if someone could help with my assignment. I've pretty done finished the work but cannot figure out why it only prints the last one added. Here is my code. The way things are done...
2
2068
by: Bill | last post by:
I have a 200 record database that includes a date/time field, AnnivDate, for a wedding anniversary. AnnivDate has nulls and some incorrect year data. I have been creating the Access database...
0
7373
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,...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.