0

Timestamp now() minus 3 minutes

Have a button, by which I create a timestamp now() … but want the time being displayed to be 3 minutes before - tried with 

time := now() – 3 

but of course didn’t work 

i‘d be thankful

happy Easter!

4 replies

null
    • Ninox developper
    • Jacques_TUR
    • 1 yr ago
    • Reported - view

    On computers, time is a value in milliseconds counted from 1 January 1970.

    If we want to decrease the current time by 3 minutes, we have to remove 1000ms * 60sec * 3mn . To do this, convert the now() function to a number, then subtract 180,000ms and convert it to datetime :

    time := datetime(number(now()) - 1000 * 60 * 3);
    • Astavakra
    • 1 yr ago
    • Reported - view

    Merci beaucoup

    • Ninox developper
    • Jacques_TUR
    • 1 yr ago
    • Reported - view

    I have been looking at the possibilities of subtracting from the now() function. now() is of type timestamp and it accepts subtraction with values of type time, date, timestamp and timeinterval.
    So you can use the time() function to create a time value of 3 minutes and subtract it from now() : 

    var myTime := now()-time(0,3,0,0)
    

    see time function on Ninox documentation : https://docs.ninox.com/en/script/function-overview/functions/time.

    This solution is cleaner than the one I proposed before.

    • Astavakra
    • 1 yr ago
    • Reported - view

    Even better - thx 🙏🏼 

Content aside

  • 1 yr agoLast active
  • 4Replies
  • 147Views
  • 2 Following