Question

I have a Text box Infopath that displays the current time using this function:

(substring-after(now(), "T")

I also have a Drop-Down list called "Location" that has the following values:

1.Boston

2.India

3.London

I want to modify this function to set the current time to always display the current time in Boston whether the user is from India or London.

I believe that inputting an If Statement that follows these conditions:

  1. If Location (Drop down list) = "London" - Then use (substring-after(now(), "T") subtracted by 5 hours.

  2. If Location (Drop down list) = "India" - Then use (substring-after(now(), "T") subtracted by 11 hours.

  3. If Location (Drop down list) = "Boston" - Then use (substring-after(now(), "T").

I'm relatively new to Xpath and require assistance.

Était-ce utile?

La solution

The easiest way is to subtract the hours before ripping the time off the end with substring.

substring-after(addSeconds(now(), -3600 * 5), "T")

WARNING: Remember the current time (now()) is calculated from the LOCAL machine. So if a person in London opens the form they will already be at London time and then your code will subtract 5 hours on top of that - making it incorrect.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top