08-23-2010 05:37 PM
I've got a data file where they saved three columns, seconds since midnight, day of year, and year. I'm trying to create a LabVIEW timestamp from these three numbers. From seconds since midnight, I can create sec, minutes, and hours. If I feed these into a time cluster with Day of Year and Year, the output timestamp is 0. Doesn't work. Although it has a Day of Year input element, apparently the Date/Time to Seconds function requires day of month and month to work.
The only obvious solution I can imagine at this point is to calculate month and day from day of year, which would involve a month lookup table and a leap year check.
Any clever solutions I'm missing?
DaveT
Solved! Go to Solution.
08-23-2010 05:49 PM
The day of week and day of year can be 0 and it will still work. But the month and day of month are required. I guess you would have to look up the month and day from day of year with a leap year check.
08-23-2010 05:50 PM
08-23-2010 06:06 PM
Thanks, Dennis! I did do a search, but didn't find that. I was hoping there was an easy trick like that.
Cheers,
DaveT
05-26-2014 11:27 AM
I have another way, the DBL conversion VI converts time to a "numeric value" that started counting since the year 1901. Now you can do some math in a seperate VI to determin how many "numeric values" is 1 year, 1 day, 1 second. Then do your math to add up all "numeric values" and then convert your DBL to timestamp again.
05-26-2014 12:05 PM
@Mattjk wrote:
I have another way, the DBL conversion VI converts time to a "numeric value" that started counting since the year 1901. Now you can do some math in a seperate VI to determin how many "numeric values" is 1 year, 1 day, 1 second. Then do your math to add up all "numeric values" and then convert your DBL to timestamp again.
This can get a bit complicated, for example make sure you take care of leap years and such.
05-26-2014 03:04 PM
You don't need to worry about a leap year doing it this way.
Example:
Seconds since midnight: say 60
Day of year: say 222 (60seconds x 60 minutes x 24 hours) X 222= 19180800
Year: say 2014 (Jan. 1st 2014 at exactly 12:00am) (using code) = 3471397200
Each year after = 31536000
So just add all the numbers together and use the number to timestamp VI in the timing pallet to convert back to a date.
There is a little bit of work with the year because you can't assume that
Year 1900 to 2014 is 114 years which is
114 X 31536000
First calcualte an offset value from December 31st 1903 at 7pm to any year that starts with Jan.1st at 12am.
Then add Years after (multiplied by 31536000)