Reputation: 121
My time comes back from a database query as following:
kdbstrbegtime =
09:15:00
kdbstrendtime =
15:00:00
or rather this is what it looks like in the command window.
I want to create a matrix with the number of rows equal to the number of seconds between the two timestamps. Are there time funcitons that make this easily possible?
Upvotes: 0
Views: 979
Reputation: 110
First you have to convert kdbstrendtime
and kdbstrbegtime
to char
by datestr
command, then:
time = datenum(kdbstrendtime )-datenum(kdbstrbegtime )
t = datestr(time,'HH:MM:SS')
Upvotes: 0
Reputation: 32930
Use datenum
to convert both timestamps into serial numbers, and then subtract them to get the amount of seconds:
secs = fix((datenum(kdbstrendtime) - datenum(kdbstrbegtime)) * 86400)
Since the serial number is measured in days, the result should be multiplied by 86400 ( the number of seconds in one day). Then you can create a matrix with the number of rows equal to secs
, e.g:
A = zeros(secs, 1)
I chose the number of columns to be 1, but this can be modified, of course.
Upvotes: 1