Using System.DateTime in a Timetable

18 ビュー (過去 30 日間)
Sebastian Ehrismann
Sebastian Ehrismann 2021 年 6 月 18 日
コメント済み: Steven Lord 2021 年 6 月 22 日
Hello everyone,
i am importing Data from a Database and want to save the timestamps and the values in a timetable. However the Time gets imported as System.DateTime, which I cannot use in a timetable, at least I get an error, when I try.
The System.DateTime 'netTime' looks like this:
K>> netTime(1)
ans =
DateTime with properties:
Date: [1×1 System.DateTime]
Day: 29
DayOfWeek: Thursday
DayOfYear: 119
Hour: 6
Kind: Unspecified
Millisecond: 300
Minute: 0
Month: 4
Now: [1×1 System.DateTime]
UtcNow: [1×1 System.DateTime]
Second: 0
Ticks: 637552728003000000
TimeOfDay: [1×1 System.TimeSpan]
Today: [1×1 System.DateTime]
Year: 2021
MinValue: [1×1 System.DateTime]
MaxValue: [1×1 System.DateTime]
What i Want is to only the Time hh:mm:ss:ms from this "cell" to use in a TT.
Can anyone tell me what I need to do?
Thanks in advance

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 6 月 18 日
This converts the System.DateTime variable returned by netTime to a datetime variable, which can then be used with timetable:
t = netTime(1); % t is System.DateTime variable
% convert to datetime variable
t2 = datetime(t.Year, t.Month, t.Day, t.Hour, t.Minute, t.Second, t.Millisecond)
  7 件のコメント
Scott MacKenzie
Scott MacKenzie 2021 年 6 月 22 日
You're welcome.
Obviously, issues with execution time relate to retrieving data from the database. I really don't have any insights to offer on this. Sorry.
Steven Lord
Steven Lord 2021 年 6 月 22 日
Profile the code (possibly on a small sample of your data) to identify the bottlenecks. Depending on what the code in the bottlenecks is doing it may be possible to speed them up, but it could be difficult if not impossible to offer specific guidance without seeing the actual code you're executing.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by