I have a table with a column ReceivedOn of type DateTime. I am executing a stored procedure with select statement like this:
Select
CONVERT(DateTime,ReceivedOn)[Date/Time], MessageText[Event]
From
RawFeed
Where
ATM = (Select Code From ATM Where ATM = @ATMID)
AND ReceivedOn Between @From And @To
Order By
ReceivedOn Desc
I am storing stored procedure result in a DataTable object. and showing this object on my .aspx page
dtReturn = sspObj.ExecuteDataTable();
return dtReturn ;
DataTable object is converting into HTML table using some function storing result in table object and adding that to the page
tOutput = Generix.convertDataTable2HTMLTable(dtOutput, true, true, false);
Page.Controls.Add(tOutput);
But instead of displaying values as
2012-10-05 16:40:35.234
I get output like this:
2012-10-05 04:40:35 PM
It’s not a SQL issue; SQL is returning a datetime, which is getting formatted by C# into the output you are seeing. If you want SQL server to return a varchar (string) representing the date in your format, try:
See Cast and Convert for more details.