How to readjust a timestamp?

Illustration
Kofi Agyemang Amankwah - 2023-07-24T14:45:23+00:00
Question: How to readjust a timestamp?

Hi all,   I am trying to read some data collected. I made a mistake and inputted 07/24/2023 instead of 07/23/2023. Now the matlab date which is in a number format is unable to correctiy read the data based on these timestamps.   Please, I will apprciate it if any one can help me adjust the matlab date 07/23/2023 to 07/24/2023 or any suggestions will be appreciated.   NOTE: the malab date is in a number format eg. 7.390905000610648e+05

Expert Answer

Profile picture of Kshitij Singh Kshitij Singh answered . 2025-11-20

"the malab date is in a number format eg. 7.390905000610648e+05"
The number format is the number of days since Jan 0, 0000 (see: datenum), e.g.:
 
 
datenum('07/23/2023')
ans = 739090
datenum('07/24/2023')
ans = 739091
"help me adjust the matlab date 07/23/2023 to 07/24/2023"
 
In order to adjust the date forward by one day (e.g., from 07/23/2023 to 07/24/2023), you can add 1 to the number.
 
num = 739090.5000610648;
datetime(num,'ConvertFrom','datenum')
ans = datetime
   23-Jul-2023 12:00:05
num = num+1;
datetime(num,'ConvertFrom','datenum')

ans = datetime
   24-Jul-2023 12:00:05

(If you want to go from 07/24/2023 to 07/23/2023, you would subtract 1. Your question says you want to do both.)


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!