How do you change field type from string to date

Options
Hello!

I'm using Crystal Reports 10 and using a RE export to a CSV file that I'm then saving as an Excel 97-2003 file



One of the fields is a date but it is importing into CR as a string so I am unable to do the formating I want on it (I just want it to list month/year)



Any advice on this?



thanks!
Tagged:

Comments

  • Use the Date function.  Put the text string in parenthesis:  Date (string)
  • Chester Bammel:

    Use the Date function.  Put the text string in parenthesis:  Date (string)

    Thanks for responding Chester but I do not understand what you mean, by using the date function.

  • The text needs to be parsed, converted into numbers and then formatted to a date data type.  The following formula can be altered depending on how the YYYYMMDD is organized:

    If Length ({TABLE.FIELD}) = 8 THEN

       Date (Val ({TABLE.FIELD}[1 to 4]),

             Val ({TABLE.FIELD}[5 to 6]),

             Val ({TABLE.FIELD}[7 to 8]))
  • Create a new formula.  In the formula window, there are 3 sections - one of which is Functions.  Expand the +, then expand the + next to Date and Time.  There you will see the list of functions for date.



    In the formula box, you can simply enter the text as follows:  Date(your field name)

    This is assuming your string is in a format that resembles a date.  For instance:  date (10/4/15).

    You can verify by hitting the "Check" icon that looks like 'x-2' with a checkmark under it that is right below the Save and Close button.

    Then, just drop that formula into your report.
  • Thank you both!  I did get it to work  :)
  • You’re very welcomed.

     

     

    Chester
    Bammel

    Business
    Analyst

    IT
    Enterprise
    Services

    Division of
    Information Technology

    Sam
    Houston State University

    Box
    2397 Huntsville, TX  77341

    Office - (936) 294-2351

     

     

Categories