question

fritterhat-9706 avatar image
0 Votes"
fritterhat-9706 asked JarvanZhang-MSFT answered

Generally, do you store your dateTime values as strings or Dates in your model?

Generally, do you store your dateTime values as strings or Dates in your model?

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered

Hi, fritterhat-9706. What value do you want to save in the model class? If you just want to save the date, month and etc, it's better to use the string type. If you want to get the more details about the 'date', you could use the DateTime instead.

public class TestModel
{
    public string StartDate { get; set; }
    public string EndDate { get; set; }
    public DateTime theDate => DateTime.Parse(EndDate);
}


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.