Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask 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
18 - Pollux
18 - Pollux

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