473,946 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ToStri ng("MM/dd/yyy hh:mm:ss:fff")

Thanks,
jim
Nov 16 '05 #1
3 1677
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 misunderstandin g, please feel
free to let me know.

As far as I know, we can use datagridcolumns tyle 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 DataGridTextBox Column.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.mic rosoft.com> wrote in message
news:aR******** ******@cpmsftng xa10.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 misunderstandin g, please feel
free to let me know.

As far as I know, we can use datagridcolumns tyle 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 DataGridTextBox Column.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
6514
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 be able to add them in a stored procedure. When I use StartDate + StartTime I get a date two days earlier than expected. For example, instead of 7/16/2004 3:00:00 PM StartDate + StartTime returns 7/14/2004 3:00:00 PM.
4
2711
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 does'nt have any time frame Query is shoing only dates; But ASP.NET dategrid showing Time frame also, How can remove the time frame in datagrid
3
2155
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 the time (e.g. 12/7/04 12:00 AM). How do I get rid of the time from textbox and show only the date? 1. VS textbox Properties:
3
4245
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 datatable feeding the datagrid control. Both are of the DateTime Type. How do I get the time field to display only the Time, and not the date, which is apparently the default.
9
1985
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 date displayed has the following format, the same as in the XML file:
6
2980
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
1339
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 diffrent columns when different values( currently 2) from the drop down are chosen. I also have a Datagrid with bound columns which has all the columns that can be returned, this datagrid has a couple of date columns when i select one value from the...
0
1426
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 a DataGrid with BoundColumn rows that are dates and times. Can one somehow in specifying the formatting for a date column say "date the bound date and treat it as UTC and convert it to PST when the page is rendered"? Or does one have to go thru...
6
3319
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 "2:50:54 PM". But after the row is inserted and I check the data in the database, the column data is set to "1/7/2007 2:50:04 PM" (notice today's date in front of the time). If I insert data directly into the table in the Enterprise Manager, the...
0
11556
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11145
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10683
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6106
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4932
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3532
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.