Convert from Microsoft's DateTime Structure to readable date

I have a dataset with collection intervals marked with numeric identifiers such as the following:
- 635364711700000000 - 635364711800000000 -635364711900000000
These IDs are from Microsoft's DateTime Structure (see link below). Does anybody know if Matlab has functionality to convert from the DateTime Structure to a timestamp in human readable format?

 채택된 답변

José-Luis
José-Luis 2014년 6월 11일
No, I don't think there is. But if you don't care about leap seconds it is not too complicated:
epoch = datenum(1,1,0);
matlab_time = epoch + MicrosoftTime / (86000 * 10^7); %1 unit Microsoft time = 100 nanoseconds
e.g., taking care of the fact that MicrosftTime should not be stored as double:
datestr(double(datenum(1,1,0) + int64(635364711800000000) / (86400 * 10^7)))

댓글 수: 6

Thanks, just a quick followup before I accept this. I'm interested in the timestamp down to the "seconds" level of detail, how would you modify this command to accomplish that?
datestr(double(datenum(1,1,0) + int64(635364711800000000) / (86400 * 10^7)))
What do you mean?
datevec(double(datenum(1,1,0) + int64(635364711800000000) / (86400 * 10^7)))
For example, the below command using "635364711800000000" as the input returns May 23rd, 2014. However, there's no finer time information such as hours, minutes, seconds, which all show 0.
>> datevec(double(datenum(1,1,0) + int64(635364711800000000) / (86400 * 10^7)))
ans =
2014 5 23 0 0 0
My bad, didn't remember that you get rid of the fractional part when you divide an integer. Please try:
numDays = double(int64(635364711800000000) / int64(86400 * 10^7))
remainder = double(mod(int64(635364711800000000) , int64(86400*10^7)))
datevec(datenum(1,1,0) + numDays + remainder / (10^7*86400))
That looks great, thanks!
My pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

질문:

Tim
2014년 6월 11일

댓글:

2014년 6월 11일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by