Home Forums SQL Server 7,2000 T-SQL convert military time to standard time RE: convert military time to standard time

  • wlblee38 (1/7/2011)


    I'm not that familiar with functions is there a way to do this with SQL? Here's what i revise from your example.

    :ermm: That was SQL. Proc based, but SQL. If you're talking about inlineSQL for a table statement...

    select mycol, LEFT( mycol+ REPLICATE( '0', 6), 6)+STUFF( STUFF( mycol, 3, 0, ':'), 6, 0, ':')+ CONVERT( VARCHAR(25), CONVERT( TIME, mycol), 100)from militarytbl

    This will have some trouble running, primarily because you broke the layering. I broke out each step above to help you see how each piece modified the data. I'll get back to you about the final, all in one, it'll take some manipulation to combine properly... and if you're using the TIME datatype as I see above, are you on SQL 2k8 or are you actually on SQL 2k?


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA