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!

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

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

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