Topic: detect if morning or evening

Hello derek, dmitry

Please help how to detect if current time is morning or evening..

I need to get the time stamp when click save. I have two fields in the table; Field_morning and Field_evening
When I click the button if morning it will save to field_morning and Field_evening is empty,
else if evening it will save to Field_evening and Field_morning  no change.

I want the user to just click one button and system will take care of recording it and input the correct value in the field. I want to use button [save record] to avoid scripting, problem is both field will be populated same time.


Thanks again in advance!

2 (edited by derek 2019-03-13 02:35:18)

Re: detect if morning or evening

Hi,
One simple way might be to remove the problem and only have one datetimestamp field and then use calculated fields to display morning(AM) and evening(PM) - see attached.
This option requires no script but does set the datetimestamp when you OPEN the form rather than SAVE the form - I don't know if this is critical to your requirement.
But there are other ways to do it as well if the above option doesn't suit.
Derek.

Post's attachments

Attachment icon ampm.zip 336.54 kb, 15 downloads since 2019-03-12 

Re: detect if morning or evening

derek wrote:

Hi,
One simple way might be to remove the problem and only have one datetimestamp field and then use calculated fields to display morning(AM) and evening(PM) - see attached.
This option requires no script but does set the datetimestamp when you OPEN the form rather than SAVE the form - I don't know if this is critical to your requirement.
But there are other ways to do it as well if the above option doesn't suit.
Derek.

Thank you for this example, substr is the key here. im still playing with it to fit my requirements.
I need to record for example an electric meter in morning and evening. only one row per day, (date is unique)
user will input the value for AM click save. then comeback and input value at evening. then system fill the rest of information.
Ex.
Date, AM value, AM time, PM value, PM time, consumption. etc

so system will automatically save the time in correct field AM or PM. i can put 2 Edit box for am and pm, still i need to disable/hide one of them when its AM or PM just to make sure user dont make mistake where to put the value.

i want it to be user friendly as much as possible thats why one Editbox is good way, just input and save. quick timestamp of value

4 (edited by derek 2019-03-15 13:36:16)

Re: detect if morning or evening

Hi,
As per your description of the requirement, I'd probably do it something like this (see attached).
The user doesn't have to do anything except enter readings (the program creates a new row automatically for the current date (if it doesn't already exist) and puts readings into the correct 'morning' or 'evening' field depending on the current time). 
For information, the last week's worth of readings are displayed and there is also an option to manually maintain dates/times/readings to correct for any errors or omissions (mistakes are bound to be made!).
Perhaps this approach gives you some ideas.
Derek.

Post's attachments

Attachment icon em2.zip 455.18 kb, 30 downloads since 2019-03-15 

Re: detect if morning or evening

derek wrote:

Hi,
As per your description of the requirement, I'd probably do it something like this (see attached).
The user doesn't have to do anything except enter readings (the program creates a new row automatically for the current date (if it doesn't already exist) and puts readings into the correct 'morning' or 'evening' field depending on the current time). 
For information, the last week's worth of readings are displayed and there is also an option to manually maintain dates/times/readings to correct for any errors or omissions (mistakes are bound to be made!).
Perhaps this approach gives you some ideas.
Derek.

perfect works like a charm! thank you for creating this derek!
learn a lot of of technique with this smart little software smile