188
Views
4
Comments
Solved
How to round time to the nearest quarter hour
Question

I am using a time widget i need to set the time on load to nearest quarter hour. for example if current time 10:43, i need to set to 10:40 or even 10:45. How do we do this in outsystems.

2024-07-29 13-18-02
Vitalii Martynenko
Solution

prashanth ms,

Let's say your old datetime value is in OldTime variable.

New time rounded to nearest quater can be calculated the following way:

NewMinute = Round(Minute(OldTime)/15) * 15;

NewTime(Mod(Hour(OldTime) + Trunc(NewMinute/60), 24), Mod(NewMinute, 60))

UserImage.jpg
Prash

Vitaly Martynenko wrote:

prashanth ms,

Let's say your old datetime value is in OldTime variable.

New time rounded to nearest quater can be calculated the following way:

NewMinute = Round(Minute(OldTime)/15) * 15;

NewTime(Mod(Hour(OldTime) + Trunc(NewMinute/60), 24), Mod(NewMinute, 60))

thanks for this quick work around logic. 


2026-06-05 12-38-17
Eduardo Jauch

Hello prashanth,

I don't think there is anything "ready" for this.

But you could use the Minute builtin action to retrieve the "minute part", round it using logic and then build the time again using the NewTime builtin action.

Cheers.

UserImage.jpg
Prash

Eduardo Jauch wrote:

Hello prashanth,

I don't think there is anything "ready" for this.

But you could use the Minute builtin action to retrieve the "minute part", round it using logic and then build the time again using the NewTime builtin action.

Cheers.

thanks. 


2024-07-29 13-18-02
Vitalii Martynenko
Solution

prashanth ms,

Let's say your old datetime value is in OldTime variable.

New time rounded to nearest quater can be calculated the following way:

NewMinute = Round(Minute(OldTime)/15) * 15;

NewTime(Mod(Hour(OldTime) + Trunc(NewMinute/60), 24), Mod(NewMinute, 60))

UserImage.jpg
Prash

Vitaly Martynenko wrote:

prashanth ms,

Let's say your old datetime value is in OldTime variable.

New time rounded to nearest quater can be calculated the following way:

NewMinute = Round(Minute(OldTime)/15) * 15;

NewTime(Mod(Hour(OldTime) + Trunc(NewMinute/60), 24), Mod(NewMinute, 60))

thanks for this quick work around logic. 


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.