Need to convert Time data to a string

Posted on 2006-05-18
Last Modified: 2012-05-05
I have a SQL query that returns a time.  i cannot for the life of me get it converted to a string.

I have tried everything I can think of.  HELP!!!
Question by:danielrsmith
    LVL 46

    Accepted Solution

    Hi danielrsmith,

    Try something like this....

        Dim dTime As DateTime = "your time"
        Dim TimeString As String
        TimeString = dTime.ToString


    LVL 3

    Assisted Solution

    You have a bunch of options,

    changing your sql command to use convert is probably the easiest
    SELECT  convert(varchar(50), yourdate, 101) as yourdatestring       *** 101 gives mm/dd/yyyy   1 gives a 2 dig year instead.

    Or in your code use format(somedate,"d")

    If your putting the date in a datagrid in an page and your trying to use the format property of a cell, make sure you turn off html encoding for that cell or it will not work.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    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 …
    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 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

    17 Experts available now in Live!

    Get 1:1 Help Now