In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to truncate timestamps to the nearest minutes?

abdullah_noor23
7 - Meteor

Hi I have a workflow that generates certain columns using DateTimeNow(). However, I need to truncate the seconds into the nearest minute adding another formula tool. Can anyone tell me how to do that?

 

For example, In the attachment,

I want the Effective Start Date to be rounded to 2023-04-11 16:45 instead of 2023-04-11 16:45:02

abdullah_noor23_0-1681426572457.png

 

3 REPLIES 3
alexnajm
19 - Altair
19 - Altair

How about DateTimeFormat(DateTimeNow(),”%Y-%m-%d %H:%M:00”) ?

 

you could also replace the date time now part with your already calculated columns

Yoshiro_Fujimori
15 - Aurora
15 - Aurora

@abdullah_noor23 ,

Added a check to see if it is before / after the half of the current minute, to get the "nearest minute".

 

Formula

isRoundUp = DateTimeSeconds([DateTime]) >=30

RoundDown = DateTimeFormat([DateTime],"%Y-%m-%d %H:%M:00")

RoundUp = DateTimeAdd([RoundDown],1,"minutes")

Result = IF [isRoundUp] THEN [RoundUp] ELSE [RoundDown] ENDIF

 

Output

Yoshiro_Fujimori_0-1681433553773.png

 

I hope this works for your case.

 

abdullah_noor23
7 - Meteor

thanks man

Labels
Top Solution Authors