Convert date format from DB for app

  • Date format in DB is 2002-11-04 00:00:00.000, I need to convert this to 04/11/2002 (UK date format). Have tried CONVERT(VARCHAR(10),103) but with no results. I would appreciate any advice.

  • If it's stored as a varchar you'll need to convert it to a datetime first then convert it to the formatted date you want.

  • p.bradley (3/12/2015)


    Date format in DB is 2002-11-04 00:00:00.000, I need to convert this to 04/11/2002 (UK date format). Have tried CONVERT(VARCHAR(10),103) but with no results. I would appreciate any advice.

    CONVERT(VARCHAR(10),103) will not do it CONVERT(VARCHAR(10),yourdate,103) might.

    What app are you using? Can it format?

  • Note that if you format your date it won't be a date any more and it will be a string. String dates will give you problems if you try to order them.

    That's why dates should be formatted on the presentation layer.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Correction, my apologies, I am using CONVERT(VARCHAR(10),GETDATE(),103). The application is software text messaging which requires the date in dd/mm/yyyy, as far as I know it does not format.

  • p.bradley (3/12/2015)


    Correction, my apologies, I am using CONVERT(VARCHAR(10),GETDATE(),103). The application is software text messaging which requires the date in dd/mm/yyyy, as far as I know it does not format.

    That should work fine SELECT CONVERT(VARCHAR(10),GETDATE(),103) returns 12/03/2015, what problem are you having with it?

Viewing 6 posts - 1 through 5 (of 5 total)

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