Session["DateOfBirth"]
is collecting datetime from database (SQL using Entity Framework) but I only want to show date not time.
Here is my code:
View model class:
[Display(Name = "Date of Birth")]
[Required(ErrorMessage = "Date of Birth required")]
[DataType(DataType.Date)]
public string dob { get; set; }
Controller class:
Session["dob"] = umail.u_dob;
Index view:
<div class="col">
<h6>Date of Birth</h6>
<p class=" ">@Session["dob"]</p>
</div>
Output screen:
below code is Working in my case. use this code in controller
Session["dob"] = Convert.ToDateTime(Session["dob"].ToString()).ToShortDateString();