Hi,
I have encountered the problem:
1. I have a sql server with a table in it.
2. One of the column's type in the table is datatime.
2. I have a form taht contains a datagrid control.
3. I attached the datagrid to the table in the DB.

One of the cells in the table contains the following data (datetime):
11/8/2004 4:14:37 PM
(I can see that if I open the DB through the server explorer in visual
studio).
When I run my application, and the DB is attached to the grid, the cell
contains:
11/8/2004
(thats what I see in the grid when I run the application- the time is
missing).

Is there something I forgot to do?
Do I have to configure something?
Help will be appreciated,
Regards,
Ram.

RE: DataGrid with DateTime by v-jetan

v-jetan
Mon Nov 08 19:54:17 CST 2004

Hi Ram,

Based on my understanding, you want to display customized string
representation for datetime type column in datatable.

Default, if we do not specify any format string for the datagrid, it will
call each column's ToString() method to get the string representation of
that datacolumn. So you will get only the year, month and date
representation.

If you wanted to display customized string for the datetime type, we may
explicit set Format string for that column. This can be achieved through
adding a DataGridTableStyle with DataGridTextBoxColumn into the DataGrid's
TableStyles property. Just set DataGridTextBoxColumn's MappingName to that
datetime type column and set customized Format string for
DataGridTextBoxColumn.Format property.

For example, to display "11/8/2004 4:14:37 PM" string for datetime column,
we may use the format string below:
MM/dd/yyyy hh:mm:ss tt

It works well on my machine.

For the details reference about the customize format string of datetime,
please refer to:
"Custom DateTime Format Strings"
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcustomdatetimeform
atstrings.asp

For example, please refer to:
"Custom DateTime Format Strings Output Examples"
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcustomdatetimeform
atstringsoutputexamples.asp
===============================================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Re: DataGrid with DateTime by Claes

Claes
Tue Nov 09 01:55:00 CST 2004

Or simply use the standard datetime format string "G"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandarddatetimeformatstrings.asp

Then you won't annoy users whose regional settings are not US English :-)

/claes

""Jeffrey Tan[MSFT]"" <v-jetan@online.microsoft.com> wrote in message
news:vTN6O8fxEHA.3436@cpmsftngxa10.phx.gbl...
> Hi Ram,
>
> Based on my understanding, you want to display customized string
> representation for datetime type column in datatable.
>
> Default, if we do not specify any format string for the datagrid, it will
> call each column's ToString() method to get the string representation of
> that datacolumn. So you will get only the year, month and date
> representation.
>
> If you wanted to display customized string for the datetime type, we may
> explicit set Format string for that column. This can be achieved through
> adding a DataGridTableStyle with DataGridTextBoxColumn into the DataGrid's
> TableStyles property. Just set DataGridTextBoxColumn's MappingName to that
> datetime type column and set customized Format string for
> DataGridTextBoxColumn.Format property.
>
> For example, to display "11/8/2004 4:14:37 PM" string for datetime column,
> we may use the format string below:
> MM/dd/yyyy hh:mm:ss tt
>
> It works well on my machine.
>
> For the details reference about the customize format string of datetime,
> please refer to:
> "Custom DateTime Format Strings"
>
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcustomdatetimeform
> atstrings.asp
>
> For example, please refer to:
> "Custom DateTime Format Strings Output Examples"
>
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcustomdatetimeform
> atstringsoutputexamples.asp
> ===============================================================
> Please apply my suggestion above and let me know if it helps resolve your
> problem.
>
> Thank you for your patience and cooperation. If you have any questions or
> concerns, please feel free to post it in the group. I am standing by to be
> of assistance.
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>



Re: DataGrid with DateTime by v-jetan

v-jetan
Tue Nov 09 20:07:20 CST 2004

Yes, this is the "Standard DateTime Format Strings" which is another option
for Ram, and the "Custom DateTime Format Strings" will give Ram some other
more customized options. Both for Sam's information.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Re: DataGrid with DateTime by Ram

Ram
Wed Nov 10 04:03:33 CST 2004

Thank you all. It works!
Ram.

""Jeffrey Tan[MSFT]"" <v-jetan@online.microsoft.com> wrote in message
news:keBNJosxEHA.3440@cpmsftngxa10.phx.gbl...
> Yes, this is the "Standard DateTime Format Strings" which is another
option
> for Ram, and the "Custom DateTime Format Strings" will give Ram some other
> more customized options. Both for Sam's information.
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>



Re: DataGrid with DateTime by v-jetan

v-jetan
Thu Nov 11 01:40:00 CST 2004

You are welcome!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.