Skip to main content
July 1, 2024
Question

Add validation difference between two date and time should not more than 24 hrs

  • July 1, 2024
  • 2 replies
  • 0 views

Hi All,

Need your help in the following issue:

Please how can I get the difference  between two dates should not more than 24 hrs? 

For example 1 :

Start Date = 7/1/2024 12:00 AM EST

End Date = 7/1/2024 11:59 PM PST

if user enter the above dates and time than Don’t allow to select since the difference is > 24 hours

Thank you in advance for your help!

    2 replies

    venkatrea696188
    July 1, 2024

    Just subtract the dates use  hour()  functions to check whether difference between the dates is greater than your requirement 

    July 1, 2024

    this might help with some logic to get you started ...

    a!localVariables(
    
    local!maxTime: addhours(ri!startTime,24),
    
    a!match(
    value: local!maxTime,
    whenTrue: local!maxTime < ri!endTime,
    then: "end time exceeds 24 hours",
    default: {}
    )
    
    
    )

    Note this uses this component ...

     [mention:d7ae9642523840f797e96e47dbfa6bae:f7d226abd59f475c9d224a79e3f0ec07]