www.webdeveloper.com
Results 1 to 5 of 5

Thread: How to insert a character between row return results

  1. #1
    Join Date
    Nov 2013
    Posts
    72

    How to insert a character between row return results

    I am querying a table that has a date in the format of "dd/mm/yyyy". I need to display the results in the format of "May'14" <--Notice the apostrophe in the middle. I can't figure out how to insert that. Below is the query that I have so far which will display the result as "May 14"

    Thanks to anyone that takes a look at this. And before anyone asks, I need to do this because this is what the client wants.

    Code:
    select Distinct to_char(DATE, 'Mon YY') from Table_Name

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,334
    Just a guess:
    Code:
    'Mon\'YY'
    Depending on programming language and context, you may need to escape the escape character, e.g.:
    Code:
    'Mon\\'YY'
    /* or */
    'Mon\\\'YY'
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Nov 2013
    Posts
    72
    Quote Originally Posted by NogDog View Post
    Just a guess:
    Code:
    'Mon\'YY'
    Depending on programming language and context, you may need to escape the escape character, e.g.:
    Code:
    'Mon\\'YY'
    /* or */
    'Mon\\\'YY'
    I had tried escaping it and none of that seems to work.

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,334
    What DBMS are you using?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,334
    This works for me directly input in PostgreSQL:
    Code:
    select to_char(now(), 'Mon\'YY')
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles