string conversion or formating question

  • itmasterw 60042

    SSCrazy

    Points: 2536

    Hi,

    I have found things online about this but nothing is working.

    I have a field that is a Varchar(20), which holds a Date in it (like this 05/04/2019).

    I need it to be in this format --> 05\04\2019.

    In other words, the slashes need to be reversed.

    Any idea how I can do this?

    Thank you

  • DesNorton

    SSC-Insane

    Points: 22440

    itmasterw 60042 wrote:

    Hi, I have found things online about this but nothing is working. I have a field that is a Varchar(20), which holds a Date in it (like this 05/04/2019). I need it to be in this format --> 05\04\2019. In other words, the slashes need to be reversed. Any idea how I can do this? Thank you

     

    Since it is a varchar field, why not do a simple REPLACE

    REPLACE(YourFieldName, '/', '\')


    How to post data/code on a forum to get the best help.[/url]
    Make sure that you include code in the appropriate IFCode tags.

  • DesNorton

    SSC-Insane

    Points: 22440

    On a side note, if you have any control over the structure, you would be better off storing the date as a DATE or DATETIME field.  Then it can be formatted as needed.


    How to post data/code on a forum to get the best help.[/url]
    Make sure that you include code in the appropriate IFCode tags.

  • Phil Parkin

    SSC Guru

    Points: 243282

    DesNorton wrote:

    On a side note, if you have any control over the structure, you would be better off storing the date as a DATE or DATETIME field.  Then it can be formatted as needed.

    +100, 'better off' is quite an understatement!

    If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Viewing 4 posts - 1 through 4 (of 4 total)

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