I have some F# code where I need to update a field in a database record. I am using the Type Provider for SQL. The table has a nullable datevalue field. When I try to update the value of the date field to DateTime.UtcNow the compiler complains that "This expression was expected to have type Nullable<DateTime> but here has type DateTime". How do I convert/cast from DateTime to Nullable<DateTime>.
My code currently looks something like follows:
for queryItem in queryResult do
queryItem.CurrentDate <- DateTime.UtcNow // This gives compiler error as described above
Regards
The comment by John Palmer above links to the solution. One needs to use the System.Nullable constructor i.e.
queryItem.CurrentDate <- System.Nullable DateTime.UtcNow
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With