Skip to Content
avatar image
Former Member

Convert String to Date and use as a Search

I'm having a bit of a mare. I'm using CR 2016 and the data field is reporting the Date as a string (01/01/2018). I have tried a number of solutions i.e. CDate etc. Although it appears to work and the fact I have a {?DateSearch} Parameter (works on my Date formats 100%). The {?DateSearch} Doesn't work when i convert the String to Date.

I Can't add anything into Select Expert - Record as it keeps saying String expected.

Am I missing somthing?

Any ideas?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Feb 27 at 02:19 PM

    Hi Paddy,

    What is the datatype of the {?DateSearch} parameter?

    Also, what database are you reporting against? Are dates being stored as a string in the database as well?

    -Abhilash

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Abhilash,

      The Parameter {?DateSearch} datatype is set as a date and is also set to true for Allow range values. The Database is OLE DB and sadly all of the dates that I want to use are Strings (dd/MM/yyyy). I require Date (dd/MM/yyyy).

      Paddy

  • Feb 27 at 02:14 PM

    Its not very fast but this does work as I have used it, assumes datestring as DD/MM/YYYY, adjust accordingly if MM/DD/YYYY.

    In this case parameter {?DateSearch} is a date.

    Date(tonumber(right(Yourdatestring,4)), tonumber(mid(Yourdatestring,4,2)),tonumber(left(Yourdatestring,2))) = {?DateSearch}

    Ian

    Add comment
    10|10000 characters needed characters exceeded