My .cs file contains this.

Model also contains the same datatype
while filling data in form i get the value as

In SQL i've kept datatype as date and in model it is necessary to keep DateTime.
I tried ParseExact(), .Date, etc but everything ultimately turns out along with time.

Can anyone please help? I tried many solutions found in this site related to this question but didn't get any help.
thank you in advance.
Add this to your Model
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
and in the .cshtml
@Html.TextBoxFor(m => m.LastPaymentDate, "{0:dd/MM/yyyy}")
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