Salesforce and other SMB Solutions are coming soon. ×

# Working with Time fields

## Recommended Posts

If I have two fields, starttime and endtime. Can I find the range of time within these two calculations?

I have a Student[table] who is registering for more than one Class[table]. These tables are related by Roster.

starttime and endtime is in Class[table].

I need to create a script/calculation that will determine if the Student is already booked in a class that runs from 10:00 - 11:55, when a new record tries to be created [in Roster] with a Class time period of 11:00 - 11:55.

This seems like it should be an easy one to figure, but I'm struggling with it.

Anyone have any ideas?

##### Share on other sites

Well, you could use the famous SmartRanges trick, but if it's same to assume that your classes all start and end at nice round intervals like hours and half hours and whatnot, and have a very finite number of possible durations (i.e., classes last one hour or they last 1.5 hours or they last 3 hours, etc), you can just do a much more simple calculated multikey.

If a Class record is given a radiobutton field to indicate its duration (or, alternatively, all classes are always of the same duration), you can generate a calc field that consists of start time plus every interval following that that a class might start at. Example: Class starts at 10:30 AM, classes at your academy only start on hours and half-hours, you create a calc like so:

Hour(Class::Start time)&":"&Minute(Class::Start Time)&"Â¶"&

Hour(Class::start time)&":"&Minute(Class::Start Time)+30&

Hour(Class::start time)+1&":"&Minute(Class::Start Time)&

Hour(Class::start time)+1&":"&Minute(Class::Start Time)+30)&"Â¶"&

Hour(Class::start time)+2&":"&Minute(Class::Start time)&"Â¶"&

Hour(Class::start time)+2&":"&Minute(Class::start time)+30

)

That's going to match the start time of the potential to-be-added class against the possibility of an already-signed-up course starting or continuing so as to conflict with it. Well, it will if you create a text field for the start time of the potential to-be-added class, at any rate:

Hour(PotentialClass::Start Time)&":"&Minute(PotentialClass::Start Time)

And you'll need your relationship to be per-the-student and per-the-date, so you aren't getting irrelevant/spurious hits for Mon-Wed classes that don't really conflict with Tues-Thurs classes or a totally different student's course schedule, etc.

But that should give you the general idea.

## Join the conversation

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×

• ### Images

• 0
By Soliant Consulting,
• 0
By Soliant Consulting,
• 0
By Soliant Consulting,
• ### Forum Statistics

• Total Topics
33.6k
• Total Posts
141.5k
×
×
• Create New...