Discussion:
rounding times
(too old to reply)
Bruce Bowler
2017-11-08 20:27:47 UTC
Permalink
Any good tricks for rounding a serial date number to the nearest minute?

Obviously I could convert to a datevec, look at the seconds part, and do
some magic, but I can't believe there's not something better (for various
definitions of "better").

Thanks!
Bruce
dpb
2017-11-08 22:23:26 UTC
Permalink
Post by Bruce Bowler
Any good tricks for rounding a serial date number to the nearest minute?
Obviously I could convert to a datevec, look at the seconds part, and do
some magic, but I can't believe there's not something better (for various
definitions of "better").
Look at DATESHIFT() with the datetime object, the optional parameter
rule,'nearest' should do what you're looking for (altho I've not ever
used it other than with either the 'next' or 'previous' options

dateshift(yourDateTimeArray,'start','minute','nearest')

seems should work...

--
Bruce Bowler
2017-11-09 16:24:32 UTC
Permalink
Post by dpb
Post by Bruce Bowler
Any good tricks for rounding a serial date number to the nearest minute?
Obviously I could convert to a datevec, look at the seconds part, and
do some magic, but I can't believe there's not something better (for
various definitions of "better").
Look at DATESHIFT() with the datetime object, the optional parameter
rule,'nearest' should do what you're looking for (altho I've not ever
used it other than with either the 'next' or 'previous' options
dateshift(yourDateTimeArray,'start','minute','nearest')
seems should work...
Sure does!

Thanks!

Loading...