Day and Time in Dropdown

Hi Guys,

In the above drop down screenshot, I want to dynamically select today’s day of the week (current day of the system) and current time +1 hour (time is only required on hourly basis for e.g. if the current time is 8:30AM then the dynamically selected time should be 9AM).

Please help

Thanks & Regards,
Harshit

Hi @AskHarshit,

You can use the DateTime class to obtain the current date and time to compare against.

Now.DayOfWeek

Now.Hour

Now.Minute

And to get AM/PM you can use the .ToString to format the time object
Now.ToString(“tt”)

You will need to determine how many minutes allows for your to round up vs retaining the current hour (e.g. does 8:29 → 9:00 or does 8:29 → 8:00?)
After you determine when to round up, you need to get that future day/time and then parse the DateTime properties mentioned above to be able to select the day/time in your drop down boxes.

Remember to create an instance of the DateTime object and use that variable throughout your checks. If you run Now over and over, you may have part of your process thinking it is 11:29 and another part of the process thinking it is 11:30

Thanks

1 Like

Check below link for dynamically selecting date.

Check below link to add hours/days/year to your date.

1 Like