Preserve data time format while using num2str

Hi, 

I have a 1 month long time series. What I need to determine is how this data behaves on average every 1 hour of a 24-hour day. So I want to end up with mean and standard deviation values for each hour going from 0 to 23. One may image a plot where the x-axis is Hour of day going from 0 to 23, and the y axis would be mean and SD derived over a 1 month period. 

Now the issue is that the datetime numeric wave is not consistent throughout. Meaning, for some days, some hours are missing, on other days, only 40 minutes (random value) of data is available for an hour etc. On some days, entire hours are missing. 

I'm trying to figure out a smart way to do this. Currently I'm writing a brute force algorithm which is splitting the data into multiple waves where each wave corresponds to a particular day of the month. Then I want the program to go through the wave, averaging values that have the same "hour" value on their timestamp. To do this, I want to use num2str(timewave), and then grep the common hour indices out. But when I run num2str, it gives me a text wave containing large values in seconds. I want to retain the date time format in the text wave. 

Kindly advise how to retain the format in text datetime wave, or also if you know of a better, simpler way (some libraries I may not have dug into yet) to pull off this whole task.

Thanks a lot, 

Peeyush 

Date/Time waves only contain a specific number of seconds as value, and the date and hour you see is only for display purposes. So of course num2str() just gives you the contents (seconds) as a string value. If you want to work with the date/time format itself you first have to convert the seconds to a formatted output such as Igor is doing for you automatically when viewing everything in a table or graph. What you are looking for is the Secs2Time() function. Use this with option 2 and then cut out the hour. You may convert this back to a number via str2num() for further processing. Here's some code:

Function getHour(Variable secs)
    String timeStr = Secs2Time(secs,2)
    return str2num(timeStr[0,1])
End

 

Plus, of course, is the fact that the conversion isn't really necessary. Since the seconds start on Jan 1, 1904 at midnight, you can convert the seconds to seconds since midnight with mod(seconds, 86400). Then, each hour is simply every 3600 seconds.