Help with Formula for Today's date and a set time (07:30:00) - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Help with Formula for Today's date and a set time (07:30:00)

Last post 07-31-2022 12:20 AM by rticehurst. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-29-2022 02:00 AM

    Help with Formula for Today's date and a set time (07:30:00)

     I am rebuilding some old Sharepoint Designer forms with InfoPath.  The forms support a sharepoint list that we use in the pharmacy for recording the prescription orders received from the hospital wards (in New Zealand).  Each morning the staff arrive and there will be a heap of prescriptions received overnight and staff need to enter them in the list with a date and time received of today's date and a specific time.  The field is defaulted to Now() and i have a button (javescript) on the old form that the staff simply click and it populates today's date and the time of 07:30.

    I've created the form and added some buttons but have become stuck on the formula that i require.  I have seen various posts  on this forum related to this but none that cover this specific issue.  The secondary challenge is that InfoPath creates the date time control formats as two fields - one with the date (date picker) and the second with the time (text).  Existing posts that describe a formula for a button to complete the date (eg add 7 days) put the same value in both fields but that then fails the validation step.

    I can;t post images but when i open the form the two fields correctly display now() with the date in the first field and the time in the second field.  I have a button for reseting the date and time to now() and that works properly - date in one field and time in the other.  My second button is labelled 'overnight' and has the following code to the set the field value:

    concat(number(substring(now(), 9, 2)), "/", number(substring(now(), 6, 2)), "/", number(substring(now(), 1, 4)), " 7:30:00")

    I know my code isn;t right - hence this post, but when i hit the button it pops the same value in both fields (29/07/2022 7:30:00) whereas i just need the specified time of 07:30:00 in the second field.  Any ideas?

    Thanks in advance

  • 07-29-2022 09:12 AM In reply to

    Re: Help with Formula for Today's date and a set time (07:30:00)

    Datetime in XML is yyyy-dd-MMTHH:mm:ss. It can be confusing, because the controls on the form may be formatting the date time, but that doesn't change the underlying value. The today function will return today's date, so you could just use something like this: concat(today(), "T07:30:00")
    Hilary Stoupa

  • 07-31-2022 12:20 AM In reply to

    Re: Help with Formula for Today's date and a set time (07:30:00)

    Thanks so much Hilary, worked a treat.
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.