sql server

  • i have one field varchar name time in data base and format is 04:00 AM

    05:00 PM now i want to display data in asp in sort order like

    04:00 AM

    06:00 AM

    02:00 PM

    i use order by in quiry but it shos data like

    02:00 PM

    04:00 AM

    06:00 AM

    so how can i convert varchar to date time so i can sort data in assending order and its not possible tomke any change in data base

    so plz help me to solve this problum

  • You can convert it in your query and that should pick it up just fine, or you can set your .net datatype to datetime...

    in SQL you'll convert like this...

    convert(datetime, ColumnName)

    However, you're better off formatting it and saving the coversion for .net.

    To do the conversion you can look in BOL under 'CAST and Convert'

    Watch my free SQL Server Tutorials at:
    http://MidnightDBA.com
    Blog Author of:
    DBA Rant – http://www.MidnightDBA.com/DBARant

    Minion Maintenance is FREE:

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply