|
Post by christopherglasow on Dec 9, 2023 7:12:50 GMT -5
Hi,
I'm looking for an efficient way to sort an array of data that has both date and time, I know I can sort date by converting to days, but looking for sorting the time in those days. I can think of soome solutions, but they are very inefficient. If any of you have any ideas I'd love your suggestions.
Thanks Chris
|
|
|
Post by tsh73 on Dec 9, 2023 8:03:28 GMT -5
convert date and time to floating point value integer part is day from start of the days fractional is (current second in a day) / (num of seconds in a day) Then sort these numbers. (with SORT command)
Excel does about the same, IMHO
Look at this
print date$() print date$("days") 'day from start of the days, now print date$("4/11/2002") 'same for given date 'note month is in the middle
print print time$() print time$("seconds") '(current second in a day) 'should be ss+60*mm+60*60*hh print time$("milliseconds")
print t$="16:15:35" 'now with given time print t$ hh=val(word$(t$,1,":")) mm=val(word$(t$,2,":")) ss=val(word$(t$,3,":")) print hh,mm,ss numDT=date$("4/11/2002")+(ss+60*mm+60*60*hh)/24/60/60 print numDT
|
|
|
Post by Rod on Dec 9, 2023 11:10:04 GMT -5
If you hold your data as yyyymmddhhmmss you already have the job done.
|
|
|
Post by Brandon Parker on Dec 9, 2023 21:18:12 GMT -5
If you hold your data as yyyymmddhhmmss you already have the job done. Make sure to store the "hh" in military time... 00-23 {:0) Brandon Parker
|
|