[Last Call] Learn how to a build a cloud-first strategyRegister Now


Showing datetime data in a datagrid  (SQL Server 2000 & vb.net)

Posted on 2006-06-01
Medium Priority
Last Modified: 2010-04-23
I would like to show both date and time for certain data being returned into a datagrid.  I would like one of the columns, which has date and time data to be displayed within the grid with both date and time data showing.  I do not know how to set the format so that this one column will show both.  Now it is defaulting to date only.
Question by:garyinmiami2003
  • 3
  • 2
LVL 10

Expert Comment

ID: 16808254
You can use a string format of "g" or "G".

g would give this: 10/12/2002 10:11 PM
G would give this: 10/12/2002 10:11:29 PM

Author Comment

ID: 16808424
That is great, Can you give me an example showing syntax of using it??.    
LVL 10

Expert Comment

ID: 16808550
Is this a web app or a windows app?

Author Comment

ID: 16808570
LVL 10

Accepted Solution

ibost earned 2000 total points
ID: 16808770
You need to add a datagrid table style

Dim ts as new DataGridTableStyle
ts.MappingName = "MyTableName"

Dim dgtbc as new DataGridTextBoxColumn
dgtbc.MappingName = "MyColumnName"
dgtbc.HeaderText = "Column 1"
dgtbc.Format = "G"




Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month18 days, left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question