Jump to content

best way to compare time values


mierlp

Recommended Posts

Hi

What's the best way to work with time controls. My table now has 2 fields of type time, namely:
- startTime
- endTime

The user must enter a period with a start-time and end-time.
For example :
Evening 6:00 pm - 10:00 pm
Night 10:00 pm - 2:00 am

I would like to check if the startTime is not greater than the endTime because then it is not correct. This works well as long as the endTime is less than 00:00.

In the situation such as 22:00-02:00 that does NOT work because startTime is greater than endTime but it is a valid period.

We do NOT use a date because they are block times for a period.

What's the best way to solve this including a controle

 

Link to comment
Share on other sites

If all you have are the hours, 02 will always be less than 22 - so you need more data than just the hours.

When crossing into a new day, you need to differentiate between dates, so you need some date reference for each point in time.

Whatever the reference is, a datetime comparison will work as long as the last datetime is defined as being x hours after the first.

Link to comment
Share on other sites

Indeed, no date is used because the times are seen as a reference framework.

- morning period falls between 7 a.m. to 12 p.m.
- afternoon falls between 12: 00-17: 00
- evening 17: 00-21: 00
- night between 21: 00: 02: 00

When filling the period times, a check must therefore be made to ensure that the start time is not greater than the end time.
That goes well until you use hours in combination of BEFORE and AFTER 00:00


In the actual planning, someone selects a period and specifies a working time. It is then checked whether the specified working time
falls within the period times.

Maybe an option to use 2 dummy date fields that are not used in the software

You will get something like:
- start Date
- startTime
- endDate
- endTime

Dates are always the current date and when EndTime is> 00:00 then EndDate + 1

Using a DateTime field in it is again cumbersome to use ReplaceDate where you only change that date.
 

Would be nice to have a time slider :) with begin/end time

Regards Peter

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...