I have an XML file giving me the value PT0S.
<Property name="TargetQuantity" type="double">
<Value>PT0S</Value>
</Property>
I have to store this value in a DATABASE table field - which is of type decimal. I have no idea how to convert this value to decimal. I am using C# to process this value. I tried to use
Convert.ToDecimal
But it does not work. Any advices would be helpful.
CodePudding user response:
You can't directly convert a timespan to a decimal. You need to decide which property you want.
See How do I convert an ISO8601 TimeSpan to a C# TimeSpan? (XmlConvert.ToTimeSpan(string)
), and then for example save TimeSpan.TotalSeconds
in your decimal column.