DateTime Displays Without Time in Datagrid Control

Mark

Member
Joined
Mar 8, 2005
Messages
9
Programming Experience
10+
I have a Windows Form application with a datagrid that is populated with a dataset based on a query of a SQL Server table. Access to the SQL Server database is by way of Web services. Some of the fields in the underlying SQL Server table are of the DateTime data type and they display properly as such (with both date and time) when the table is opened in SQL Enterprise Manager. However, these same DateTime values display in my datagrid without the time portion of the value. There is absolutely no conversion from DateTime to Date in the query that serves as the basis for the datagrid's dataset. There must be something relatively simple (perhaps with regard to a System.DateTime property setting or the like) that I am failing to take account of. Can anyone suggest what it might be?
 

The_Duck

New member
Joined
May 20, 2005
Messages
3
Programming Experience
5-10
Are you using Visual Studio ?

Are you using a SQL data adapter ?

If so I would suggest that you try previewing the data returned by your data adapter (right click your data adapter and click preview)

This way you can determine if the problem is your query or not !
 

Mark

Member
Joined
Mar 8, 2005
Messages
9
Programming Experience
10+
Yes, I am using Visual Studio .NET 2003.

Yes, I am using a SQL data adapter.

Yes, I have previewed the data returned by the data adapter, and, yes, it does not include the time portion of the DateTime fields. I, like you, would have thought that this would identify the underlying query as the problem. However, as I indicated in my original post, the underlying query is not returning expressions derived from the DateTime fields but rather the plain unadulterated DateTime fields (eg., select dtm_start, dtm_end end from timesheets). I just cannot see how the query could be the operative factor.
 

The_Duck

New member
Joined
May 20, 2005
Messages
3
Programming Experience
5-10
I presume your databinding to your grid

I believe a datacolumn can have a format property set against it. Try seting that to dd/mm/yyyy hh:mm:ss (note those an't the actual codes - you can look them up I cba :) )
---

Im not so sure about this now. Been a while since I've used datagirds and those were infragistics controls :)

Perhaps try checking the column data type in your dataset. There isn't a match between the dataset's types and SQL types. You might have to switch your dataset datetime to dbtimestamp.
 
Last edited:
Top Bottom