Converting from char to date in SSRS

  • Thanks very much for your help. I will let you know how I handle the date in SSRS in due course

  • Hello,

    Unfortunately, I probably do not have the most eloquent answer because I deal with US date formats, not UK date formats and I don't work with SSRS. With that being said, I think I can help. I can recreate your issue by running the following in SSMS:

    alter procedure sptemp

    @Thedate datetime

    as

    select @Thedate

    exec sptemp '19/01/09'

    The value that is being passed in by the report parameter ('19/01/09') is of nvarchar datatype. If you can change your report parameter that is being passed to the stored procedure to a datetime datatype, then I think that will resolve your problem.

    If that is not possible, then I would parse the nvarchar string to the ISO format and then convert to datetime:

    alter procedure sptemp

    @Thedate nvarchar(8)

    as

    declare @ISODate datetime

    set @ISODate = convert(datetime, '20' + (select substring(@theDate, 7, 2) + '-' + substring(@theDate, 4, 2) + '-' + substring(@theDate, 1, 2)))

    print @ISODate

    exec sptemp '19/01/09'

  • Sorry, I didn't see there was another page with the answer already figured out!

Viewing 3 posts - 16 through 17 (of 17 total)

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