How to combine date and time columns?
peterming
I imported dataset with the separate date and time columns in text format. How can I create a new timestamp with them?
I imported dataset with the separate date and time columns in text format. How can I create a new timestamp with them?
Hi,
It will depend a little bit on the exact format of the strings. First thing to appreciate is date/time is just the number of secs since midnight of 1/1/1904. So we have to covert your date and time fields to seconds.
The date part can be handled with the date2secs(year, month, day ) so you may need to parse out your string accordingly.
For the time part this is Hours*60*60 + min*60 +secs
With the total added together.
The alternative is to double check your import settings and set the appropriate fields to Date/time and let IP do the conversion.
Andy
June 28, 2020 at 09:32 am - Permalink
You probably can import them directly as date and time columns but it depends on the exact format of the file.
For background information, execute:
DisplayHelpTopic "Loading Delimited Text Files"
To say more I would need a sample file.
June 28, 2020 at 06:20 pm - Permalink
In reply to Quote: I imported dataset… by hrodstein
Thank you. I imported them as text because they won't show correctly at the time part with added 01/01/1904 (UTC?). Here is the screenshot of the date and time columns. Is there a direct way in Igor pro to combine them to a new "date-time" column as the excel does? I didn't do it in Excel because the dataset is too long to be read into Excel, but Igor has the capacity to read the data.
June 28, 2020 at 06:57 pm - Permalink
In reply to Hi, It will depend a little… by hegedus
Thank you. I imported them as text because they won't show correctly at the time part with added 01/01/1904 (UTC?). Here is the screenshot of the date and time columns. Is there a direct way in Igor pro to combine them to a new "date-time" column as the excel does? I didn't do it in Excel because the dataset is too long to be read into Excel, but Igor has the capacity to read the data.
June 28, 2020 at 06:57 pm - Permalink
I have posted a snippet showing how to do this conversion.
It would be better to import the date as date/time. If you attach a sample file or sufficient subset of a file, I will see if that is possible.
June 29, 2020 at 03:27 am - Permalink