C# ASP.NET retrieve DATE only issue from MS SQL 2014 -
i have table contain column having data type of date. i've checked records inside mssql, giving correct result want such 16-jun-2014.
but in c# razor code, tried retrieve with
@foreach (var row in db.query("select * table_a")) { @row.date }
in website view, giving me 16-jun-2014 12:00:00 am. can help?
.net has datetime
type, includes both date , time. have format way want be, example
@row.date.tostring("dd'-'mmm'-'yyyy");
you might need set desired culture also, if it's not correct default. can either set application's culture, or provide culture specific call
@row.date.tostring("dd'-'mmm'-'yyyy", new cultureinfo("en-us"));
of course it's better create cultureinfo
once , save in variable create every time called.
Comments
Post a Comment