How can I insert MATLAB dates into Microsoft Access using the Database Toolbox?

1 view (last 30 days)
How can I insert MATLAB dates into Microsoft Access using the Database Toolbox?
When I try to send a MATLAB serial date, they are imported a couple of thousand years in the future.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
You are receiving different dates because MATLAB and Microsoft Access store dates internally in a different format. Both products use the idea of a serial date, where each date is represented by an integer. However, Access stores dates numerically relative to 01-Jan-1900, while MATLAB represents dates numerically relative to 01-Jan-0000.
To work around this difference in dates, you need to post-process your data in MATLAB after receiving it and pre-process the data before sending it back to Access.
To convert the Access serial dates to MATLAB serial dates, simply add 693960 to them. This is the difference in days between the 0 date in MATLAB and in Access.
Putting the dates back into Access can be done similarly; simply subtract 693960 from each date in MATLAB.
You can also apply the DATESTR function to each date to produce a date in a string format which Access recognizes. The default DATESTR format (DD-MMM-YYYY) translates directly into Access.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!