Showing datetime data in a datagrid  (SQL Server 2000 &

Posted on 2006-06-01
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
    LVL 10

    Expert Comment

    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

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

    Expert Comment

    Is this a web app or a windows app?

    Author Comment

    LVL 10

    Accepted Solution

    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"




    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    I'm currently working for a company where I have to upgrade over 50 VB6 programs to VB.NET 2008.  So far I'm about half way through, and I've learned quite a few tricks that drastically improve the performance of VB.NET apps. Because there are a…
    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now