Decimal Date Format to get Max Times

조회 수: 2 (최근 30일)
Delany MacDonald
Delany MacDonald 2016년 3월 13일
댓글: Walter Roberson 2016년 3월 13일
I was given a sleep diary and asked to find the max of the hour at wake up time. I was told "To properly handle times, you will convert time in decimal-date format to time in hours using the fractional part and ignoring the day part. Each time-hour will be relative to the day recorded in the sleep diary." How would i do this?

답변 (1개)

Geoff Hayes
Geoff Hayes 2016년 3월 13일
Delany - consider the now function. It returns the current date and time as a serial date number. And, a serial date number represents the whole and fractional number of days from a fixed, preset date (January 0, 0000). So if I execute
now
at this moment in Ontario (so EDT), I observe
736401.966752053
The fractional part, so that after the decimal place, corresponds to current hour, minute and second that I ran the function. Since the serial date number is in units of days, then to convert this to hours you would need to multiply this fraction by what? Since this is clearly homework, I will leave that to you to code up.
If I multiply the fraction appropriately, I can convert this to 23:12:07 which is the time that I ran now.
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 3월 13일

Geoff, if you are in Ontario Canada, then are the time of your posting you were in EST not EDT. EDT did not start until 90 minutes after your post (an hour from now relative to my posting) ;-)

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

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by