Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

very quick, very simple sql question

  • 19-04-2006 10:53AM
    #1
    Registered Users, Registered Users 2 Posts: 871 ✭✭✭


    Was just wondering how I can set up the date format. I want it to be DD-MON-YYYY. Can anyone tell em how?


Comments

  • Closed Accounts Posts: 3,357 ✭✭✭Beano


    If you mean how it is stored in the database then you cant. It is stored in the database as a floaating point number. If you mean the format you retrieve it in using a Select statement then I use RTRIM(CONVERT(CHAR, DATEFIELD, 106)) Just replace DATEFIELD with the name of your field. This will give you the field in the format you want. Assuming is it MS SQL Server you are using.


  • Registered Users, Registered Users 2 Posts: 3,514 ✭✭✭Rollo Tamasi


    if its mysql then its

    'date' date default 00-00-0000,


  • Registered Users, Registered Users 2 Posts: 1,193 ✭✭✭liamo


    Was just wondering how I can set up the date format. I want it to be DD-MON-YYYY. Can anyone tell em how?
    The previous two replies are very helpful but they're just guessing at what you want to do because you haven't given enough information.

    What exactly are you trying to do? Do you want to INSERT a date in a particular format? Use a date in a particular format in a SELECT statement? Do you want to display dates to users in that format? In which case, if it's via an application, the question has nothing to do with SQL because the date will be formatted by the application.

    What Database Server is involved? If you're writing an application, what language are you using?

    A bit more information please. (Unless, of course, one of the previous posters nailed it).


    Regards,

    Liam


  • Registered Users, Registered Users 2 Posts: 871 ✭✭✭gerTheGreat


    just trying to pass a date from a web aplication, (as a string), via jsp to an oracle database. Problem is when I try to insert the date, it's reading it as yy-mon-dd. is there a simple way to format the insert, or can you specify that the date's recieved into the database is stored in the dd-mon-yyyy format


  • Closed Accounts Posts: 3,357 ✭✭✭Beano


    just trying to pass a date from a web aplication, (as a string), via jsp to an oracle database. Problem is when I try to insert the date, it's reading it as yy-mon-dd. is there a simple way to format the insert, or can you specify that the date's recieved into the database is stored in the dd-mon-yyyy format


    for Oracle you need to use the To_Date function. So the insert would look like

    insert into sometable(yourdatefield) values (TO_DATE('12 Apr 2006','DD MON YYYY'))


  • Advertisement
Advertisement