I’m getting the following error in a data directive.
Cannot implicitly convert type ‘System.DateTime?’ to ‘System.DateTime’
What’s the diff between System.DateTime?
and System.DateTime
(besides one has a question mark…)
I’m getting the following error in a data directive.
Cannot implicitly convert type ‘System.DateTime?’ to ‘System.DateTime’
What’s the diff between System.DateTime?
and System.DateTime
(besides one has a question mark…)
A DateTime? is a nullable DateTime ( basically the equivalent of a DateTime object that allows null values)
Pierre
Epicor uses DateTime? it allows for a Date Field to be null instead of a 10/10/1979 or w/e.
How can I cast or convert so the following code compiles
DateTime f = ttSysAgentSched_xRow.NextRunOn;
Basically I need a copy of the NextrunOn DateTime
Add Question Mark
DateTime? f = ttSysAgentSched_xRow.NextRunOn;
If you must have a DateTime of some kind, you need a default to fall back on:
DateTime f = ttSysAgentSched_xRow.NextRunOn ?? somedefaultDateTime;
I should have been more clear … How can I cast a DateTime? to a DateTime
I need to do some other time related functions that require a DateTime and not a DateTime? .
What dhewi said it should compile fine.
or use the Helper that MS has GetValueOrDefault
DateTime updatedTime = ttSysAgentSched_xRow.NextRunOn.GetValueOrDefault(DateTime.Now);