Jump to content
  • 0

Time & date fields



Hi all,

I'm working on a Submission Form that has a 'Shift Date' and 'Start time' and 'End Time' fields. I also need to calculate the number of hours between start & end time.

My problem is the Caspio calendar widget doesn't have a time picker. However after some research I came across an external JS library called flatpickr - there's been a few posts here about it. I understand about inserting the code in the footer, etc. but I'm not sure how this references my field? I can't seem to get it to work. Would someone who's used it successfully be kind enough to explain the steps in how to use it in a form?







Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi Alan,

I assume that you are referring to this forum post 

 If yes then you would need an actual field in your table to store the date and time values. It could be a text 255. In the footer you would target the respective ID's of the field to convert that to a flatpickr field. 

The next step is to use a formula to convert the two text fields into a date field and calulcalate the datediff of two fields.
Ex formula would be.

DATEDIFF(hour, CONVERT(DATETIME, [@StartTimeTextfield], 101), CONVERT(DATETIME, [@EndTimeTextfield], 101))

Hope this helps!

Link to comment
Share on other sites

  • 0

Hi @ianGPT, thanks for your reply and apologies for my late reply - I don't think I have notifications enable. I did eventually (with a little help) get the flatpickr component working. 

My next task is to try and prevent the user entering an End Time < Start Time or I end up with a minus value in the duration field! Another user has kindly provided some code which I hope to try at the weekend.

Link to comment
Share on other sites

  • 0

Hi @AlanMac,

In that case, I suggest using Rules to display error messages and disable a field. Another option is to use JavaScript that would prevent submission if End Time < Start Time. An event handler you can utilize is BeforeFormSubmit to validate if the condition meets the criteria first.

https://howto.caspio.com/datapages/ajax-loading/#:~:text=are fully loaded.-,BeforeFormSubmit,-– this event occurs

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.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   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...