Home Forums SQL Server 2008 T-SQL (SS2K8) varchar to time or datetime or ARGGHH Please help me. RE: varchar to time or datetime or ARGGHH Please help me.

  • Sean Lange (9/27/2012)


    dwain.c (9/26/2012)


    Nice set up data Sean!

    Using it, I'd like to offer a slightly less verbose solution:

    SELECT *, WaitTime=DATEDIFF(minute

    ,CAST(check_in AS TIME)

    ,CAST(STUFF(appt_time, 3, 0, ':') AS TIME))

    FROM #CheckIn

    The STUFF apparently forces the datatype to VARCHAR so minutes aren't lost.

    Both solutions return negative minutes, so you may want to take that into account.

    That's pretty cool Dwain. Didn't think of using stuff, I went the hard away around. 😛