Time datatype - Convert Time to Varchar

  • I'm currently busy converting/migrating (parts of) an existing Ms Access application to SQL Server 2008

    Part of my query:

    convert(varchar, pickupdate, 5) + ' ' + convert(Varchar, pickuptime, 108) + ' ' + postcode AS conv_item

    So what I'm trying to do here is concenate a date, a time field and textfield

    pickupdate --> Date--> desired format dd-mm-yyyy

    pickuptime --> Time --> desired format hh:mm

    postcode --> Varchar

    However I can't seem to get this working.

    Any ideas on how to solve this?

    Henk

  • What's the error that you're getting?

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • to be honest, it doesn't seem to make much sense

    Conversion failed when converting the varchar value '13-10-10 21:00:00 ' to data type int.

  • Henk de W (1/11/2011)


    to be honest, it doesn't seem to make much sense

    Conversion failed when converting the varchar value '13-10-10 21:00:00 ' to data type int.

    Ah, I'll bet postcode has numbers in it. If you do a CAST or CONVERT on postcode you'll be fine.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey (1/11/2011)

    Ah, I'll bet postcode has numbers in it. If you do a CAST or CONVERT on postcode you'll be fine.

    Second this.

  • Flip, you were right.

    See, I wasn't expecting numbers for the postcode.

    Usually it's a mix of numbers and letters. In this case it was set up differently.

    But what still bothers me is the awkward error message.

    It doesn't really send you in the right direction.

    Thanks!

    Henk

Viewing 6 posts - 1 through 5 (of 5 total)

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