Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

very quick, very simple sql question

Options
  • 19-04-2006 10:53am
    #1
    Registered Users 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 Posts: 3,514 ✭✭✭Rollo Tamasi


    if its mysql then its

    'date' date default 00-00-0000,


  • Registered Users 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 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