Conditional for DateTime objects

Hi @ismaen

Thanks in advance

i have stuck with an outage scenario for app where i’m using airdata for setting date , start time and end time based on that in web page i need to apply condition if that airdata match with current date and time then we need to show outage web page and if it doesn’t satisfy with airdata then normal web page should show.

if only date is set and time doesn’t set in airdata can we apply date and time range directly in webflow?

Hi!

This sounds like the sort of thing that’s absolutely possible! You don’t need to pull information from AirData to assign a value to a variable. You can use the Set Variable Action anywhere in a Web Flow.

If you’ve only pulled a Date from Airdata, rather than a full DateTime, you can use the DATETIME function to create a DateTime value from the Date value you already have. How you define the Time and timezone components depends on the details of your use case. And you can do this directly the Web Flow!

Does that help?

Additionally, you can run a conditional to navigate to a specific web page/web flow based on a date_time so you can display this dynamically. See screenshot below:

Hi ismaen,

we need time range (startend ,enddate) how to configure that using current time and date(now()) with some default time and date(AIRdata)
we are using airdata so that user can add multiple date and time based on that if its matching with current date and time with some range then outage webflow should be shown

For Example i’m comparing with current date NOW() =session.datetime() but need to declared session.datetime for 4 hour how to add that hour range in condition so that it satisfy with current date and except that hour range also

So what i would do is have a conditional on whatever actino you want to run it on.

You can compare date and dateTime objects using the comparison operators. Take a look at this doc here: Ordering (<, <=, > , >=)

So what you can do is something like

IF(
NOW() < ADD_TO_DATETIME(date1, 4, "hour") AND NOW() > date1,
 "Do something", 
"Do something else"
)

See ADD_TO_DATETIME docs

thank you for your input

1 Like