TIMEADD

Super User
351 Views
Highlighted
Super User
Posts: 9,942
Registered: ‎07-11-2015

TIMEADD

[ Edited ]

Does for time what DATEADD does for dates. 

 

 

TIMEADD = 
//User setttings
VAR __add = IF(MAX(Operations[Operation])="SUBTRACT",FALSE(),TRUE())
VAR __unit = MAX(Unit[Unit])
VAR __units = [Units Value] 
VAR __time = NOW() //Change to desired time value if necessary
//Constants
VAR __hour = 1/24
VAR __minute = __hour/60
VAR __second = __minute/60
//Calculations
VAR __sign = IF(__add,1,-1)
VAR __unit2use = SWITCH(__unit,"HOURS",__hour,"MINUTES",__minute,"SECONDS",__second,0)
RETURN
__time + 1*__sign * __units * __unit2use

 

 

 


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!