string conversion or formating question

  • 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

  • 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, '/', '\')
  • 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.

  • 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 you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

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

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