473,326 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How do I display time with date in a DataGrid from a DateTime data column?

I have a DataGrid where the DataSource is a DataTable that has a DateTime
column. Right now it only shows the Date, I want the date and time down to
the seconds or better. How do I set the DataGrid to display the DateTime
value in the format I want.

DateTime.ToString("MM/dd/yyy hh:mm:ss:fff")

Thanks,
jim
Nov 16 '05 #1
3 1651
Hi Jim,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to display the Date and Time
information in a grid cell. If there is any misunderstanding, please feel
free to let me know.

As far as I know, we can use datagridcolumnstyle mapping to achieve this. A
data grid has a property named TableStyles. In the styles collection, there
are mappings for the columns. You can set DataGridTextBoxColumn.Format to
"MM/dd/yyyy hh:mm:ss:fff". This will do the trick. Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #2
Thank you. That's exactly what I was looking for.

Jim

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:aR**************@cpmsftngxa10.phx.gbl...
Hi Jim,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to display the Date and Time
information in a grid cell. If there is any misunderstanding, please feel
free to let me know.

As far as I know, we can use datagridcolumnstyle mapping to achieve this.
A
data grid has a property named TableStyles. In the styles collection,
there
are mappings for the columns. You can set DataGridTextBoxColumn.Format to
"MM/dd/yyyy hh:mm:ss:fff". This will do the trick. Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #3
You're welcome, Jim.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lauren Quantrell | last post by:
I have two columns in a table: StartDate DateTime and StartTime DateTime. The StartDate column holds a value such as 07/16/2004 The StartTime column holds a value such as 3:00:00 PM I want to...
4
by: karunakar | last post by:
Hi All I was poplating Datagrid Datagrid has one of the column showing datetime field format iam showing DATE here not Necessary to populate the Time Frame Even my datebase column also...
3
by: Steve B. | last post by:
Using: VS dB: MS-Access Although the the DataGrid displays the proper date from an Access file (Date/Time DataType) an adjacent bound textbox for that same DataGrid field displays the date and...
3
by: Andrew S. Giles | last post by:
Hello, I am importing a flat text file, and putting it into a datagrid for display on a form. Currently the users have their dates and times seperated. I have two fields, therefore in the...
9
by: Shapper | last post by:
Hello, I created a dataset from a XML file. One of the dataset fields is . In an ASP:Repeater I am displaying the field. <%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %> The...
6
by: Sebastian Santacroce | last post by:
How do I get a datetime field from a database to show just time in the datagrid. The default just shows date. Thank you Sebastian
1
by: harsha reddy | last post by:
Dear All, I have a front end form which has a couple of dropdown menus which select data from the database based on the value selected, the stored procedure which the program accesses outputs...
0
by: Randall Parker | last post by:
I realize that methods like DateTime.ToLocalTime() and DateTime.ToUniveralTime() exist. But suppose one wants to query out data from a database that has UTC times in it. Suppose one wants to have...
6
by: fniles | last post by:
I am using VB.NET 2003 and SQL Server 2000. I have a table with a datetime column type. When inserting into the table for that column, I set it to Date.Now.ToString("T") , which is something like...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.