Needs help about a function with dates

nilses

Registered User.
Local time
Today, 17:50
Joined
Jan 2, 2003
Messages
45
Hello or Bonjour,

I am hoping someone could help me with this problem.

I would like to have of the assistance on a function of calculation of difference between two dates. I know that it should be used DiffDate and that in my function I must make this.

Function BetweenHours(DateStart as date, DateEnd as date) as date(I believe!!) ... and I think that it is necessary to use a select box but from here I block. Is what it is possible to use this kind of parameter ##/##/## 09:00:00 like variable to make between 09h00 and 18h00?.

My days are always 9 hours. I start at 9H00 and i finish at 18H00.

--cases 1
If DateStart and DateEnd are the same day and that DateStart is after 9h00 and DateEnd is before 18h00 then to make the difference between the two dates

DateStart(21/01/03 11:00:00) and DateEnd(21/01/03 17:00:00)
DateEnd(17:00:00) - DateStart(11:00:00) = 06:00:00

-- cases 2
If DateStart is DateEnd are the same day and that DateStart is before 9h00 and DateEnd is before 18h00 then to consider that the DateStart is 9h00 and to make the difference between the two dates

DateStart(21/01/03 07:00:00) and DateEnd(21/01/03 17:00:00)
DateEnd(17:00:00) - DateStart(09:00:00) = 08:00:00

-- cases 3
If DateStart is DateEnd are the same day and that DateStart is before 9h00 and DateEnd is after 18h00 then to consider that the date of beginning is 9h00 and completion date is 18h00 is 9 hours on the whole.

DateStart(21/01/03 07:00:00) and DateEnd(21/01/03 19:00:00)
DateEnd(19:00:00) - DateStart(09:00:00) = 09:00:00

-- cases 4
If DateStart is DateEnd are not the same day and that DateStart is after 9h00 and DateEnd is before 18h00 then to make the difference in date by considering that the day is of 9 hours

DateStart(21/01/03 11:00:00) and DateEnd(22/01/03 17:00:00)
DateStart(18:00:00 - 11:00:00) + DateEnd(17:00:00 - 09:00:00) = 15:00:00

-- cases 5 If DateStart is DateEnd are not the same day and that DateStart is before 9h00 DateEnd is before 18h00 then to consider that the date of beginning is 9h00 and to make the difference between the two dates

DateStart(21/01/03 07:00:00) and DateEnd(22/01/03 17:00:00)
DateStart(09:00:00) + DateEnd(17:00:00 - 09:00:00) = 17:00:00

-- cases 6
If DateStart is DateEnd are the same day and that DateStart is before 9h00 and DateEnd is before 18h00 then to consider that the date of beginning is 9h00 and DateEnd is 18h00.

DateStart(21/01/03 07:00:00) and DateEnd(21/01/03 19:00:00)
DateStart(09:00:00) + DateEnd(09:00:00) = 18:00:00

Any help would be greatly appreciated.

Thank you.

Nilses
 

Users who are viewing this thread

Back
Top Bottom