Highlighted

How to insert dynamic table with time values?

Community Beginner ,
Dec 07, 2015

Copy link to clipboard

Copied

Hello everyone, I have a question about inserting dynamic table with time values. Here is example of the table that I have to insert in db:

Schedule for 10/05/2016
09:30 AM - 10:00 AMRemove
10:00 AM - 10:30 AMRemove
10:30 AM - 11:00 AMRemove
11:00 AM - 11:30 AMRemove
11:30 AM - 12:00 PMRemove
05:00 PM - 05:30 PMRemove
05:30 PM - 06:00 PMRemove
06:00 PM - 06:30 PMRemove
06:30 PM - 07:00 PMRemove

I do not have a problem to insert values if my time difference in always the same. Like first few time slots are increased for 30 min but then I have a gap from 12:00pm all the way until 5:00pm. My problem is there. I do not know what is the best way to save these values. Since values are created dynamically and all of them are under the same date. If I do not have time breaks that would be really easy but in this case where I have time gap looks really complicated. If anyone can tell me what si the best way to store this in database please let me know. Thanks in advance.

Views

225

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to insert dynamic table with time values?

Community Beginner ,
Dec 07, 2015

Copy link to clipboard

Copied

Hello everyone, I have a question about inserting dynamic table with time values. Here is example of the table that I have to insert in db:

Schedule for 10/05/2016
09:30 AM - 10:00 AMRemove
10:00 AM - 10:30 AMRemove
10:30 AM - 11:00 AMRemove
11:00 AM - 11:30 AMRemove
11:30 AM - 12:00 PMRemove
05:00 PM - 05:30 PMRemove
05:30 PM - 06:00 PMRemove
06:00 PM - 06:30 PMRemove
06:30 PM - 07:00 PMRemove

I do not have a problem to insert values if my time difference in always the same. Like first few time slots are increased for 30 min but then I have a gap from 12:00pm all the way until 5:00pm. My problem is there. I do not know what is the best way to save these values. Since values are created dynamically and all of them are under the same date. If I do not have time breaks that would be really easy but in this case where I have time gap looks really complicated. If anyone can tell me what si the best way to store this in database please let me know. Thanks in advance.

Views

226

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 07, 2015 0
Adobe Community Professional ,
Dec 07, 2015

Copy link to clipboard

Copied

My suggestion is, don't save schedules in the database. Save the data in the two datetime columns startTime and endTime.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 07, 2015 0
Community Beginner ,
Dec 07, 2015

Copy link to clipboard

Copied

I have that already and is not what I need. Because if I just have stored start,end time and interval value I only can make equal time differences. What is I have 2 hours break in between time intervals?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 07, 2015 0
BKBK LATEST
Adobe Community Professional ,
Dec 08, 2015

Copy link to clipboard

Copied

pirlo89 wrote:

Because if I just have stored start,end time and interval value I only can make equal time differences. What is I have 2 hours break in between time intervals?

I don't understand what you mean. In any case, here is a dynamic example:

<cfset t1=now()>

<cfset t1_meridiem = getMeridiem(t1)>

<cfset t2=dateadd("n",180,now())>

<cfset t2_meridiem = getMeridiem(t2)>

<!--- time in 12-hour format; note the lower-case letters --->

<cfoutput>#timeFormat(t1,"hh:mm")# #t1_meridiem#-#timeFormat(t2,"hh:mm")# #t2_meridiem#</cfoutput>

<cffunction name="getMeridiem">

    <cfargument name="t" default="#now()#" required="true" type="date">

     <!--- time in 24-hour format; note the capital letters --->

    <cfset var time24 = timeFormat(t,"HH:MM")>

    <cfset var hour24 = listFirst(time24, ":")>

    <cfif hour24 LTE 11>

        <cfreturn "AM">

    <cfelse>

        <cfreturn "PM">

    </cfif>

</cffunction>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 08, 2015 0