I'm making a website using ASP.net Webpage's in WebMatrix 3. I have a database (SQL Server) with a table that contains a record of events. A InDate Column, type Date, is the primary key. However inputted data is rendered as "4/5/2014 12:00:00 AM".
Is this normal? And if it is, how do you remove the time from the date? I have tried looking up a lot of different resources. But found nothing that helped my situation.
If there is any pointers,tips,suggestions or if you need more info. Please let me know.
Thanks'
Update Here is the cshtml file as requested.
@{
Layout = "~/Layouts/_Site.cshtml";
PageData.Add("Title","Overview");
var talkDB = Database.Open("Events");
string incomingQuery = string.Format("SELECT InDate,Event FROM IncomingEvents WHERE InDate >= GETDATE() AND InDate <= DATEADD(week, 5, GETDATE())");
}
<div id="upcomingEvents" class="alertBox">
<div id="IncomingEvents">
<h3>Incoming Events</h3>
<table class="alertBox">
@foreach(var row in talkDB.Query(incomingQuery))
{
<tr>
<td>
@row.InDate
</td>
<td>@row.Event</td>
<td>edit</td>
</tr>
}
</table>
</div>
</div>
Date.ToStringwill always display this time component. You need to format the date to remove the time, for example:Date.ToShortDateString.