Date should be in this format DD-MON-YYYY  HH:MI:SS

Hi All,
I am having a column date data type ,in that i am using SYSDATE and formating as DD-MON-YYYY HH:MI:SS but result iam not getting in this format,any one please help me regarding this..
Thanks in Advance..
Edited by: 30021986 on Oct 14, 2012 1:38 PM
Edited by: 30021986 on Oct 14, 2012 3:38 PM

there is a misunderstanding.
Your database column is in a DATE type. This is a type, and thanks to this type, you can DISPLAY the date in various ways in a query editor (toad, sql developer...).
I mean, there is no various physical Date type columns, but only one called "date".
If you want to display this date in the way "DD-MON-YYYY HH:MI:SS", then convert it into "CHAR" (or VARCHAR) type with the function TO_CHAR (in oracle).
Example : to_char(sysdate, 'DD-MMMM-YYYY HH24:MI:SS").
But the result will be an alphanumeric type. You won't be able to do further operation on date, like adding a day for instance.
That's why you should keep the date format in the column of your database table, but convert it in your queries.
If you really need to have this specified format, then use the char or varchar type in your database table.

Similar Messages

  • Need regular expression for oracle date format 'DD-MON-YYYY'

    Hi,
    Can anybody tell me the regular expression to validate date in 'DD-MON-YYYY'.
    My concept is i have a table with just two columns item_name and item_date
    Both fields are varchar2 and i want to fetch those records from this table which have valid date format('DD-MON-YYYY').

    If it must be a regexp, this is a starter for you, note it carries the caveats mentioned by both posters above and in the linked thread
    mkr02@ORA11GMK> with data as (select '10-jan-2012' dt from dual
      2  union all select '10-111-2012' from dual
      3  union all select 'mm-jan-2012' from dual
      4  union all select '10-jan-12' from dual)
      5  select
      6  dt,
      7  case when regexp_like(dt,'[[:digit:]]{2}-[[:alpha:]]{3}-[[:digit:]]{4}','i') then 1 else 0 end chk
      8  from data
      9  /
    DT                 CHK
    10-jan-2012          1
    10-111-2012          0
    mm-jan-2012          0
    10-jan-12            0It will not validate content, only string format.
    And to emphasis the points made in the linked thread - dates in text columns is poor design. Always.

  • How to convert sysdate to the format dd-mon-yyyy

    how to convert sysdate to the format dd-mon-yyyy

    <how to convert sysdate to the format dd-mon-yyyy>
    This question is better answered by thinking about about how Oracle dates work. SYSDATE is a pseudocolumn (function without any arguments) that returns a date value: it already is a date. Oracle date values are stored not as we see them, say 'DD-MON-YY', but as a series of bytes with the different date components from the millennium down to the second. We NEVER see dates as they are stored but use the formats for automatic conversion.
    To display a date the way you want use TO_CHAR() with an edit mask or as others suggested change your NLS_DATE_FORMAT (thought I advise against this as most systems use DD-MON-YY and porting queries from other systems or even OTN can easily break). To change a converted string back to a date use TO_DATE() with an edit mask.

  • Convert varchar2 field into date formatted: DD-MON-YYYY

    Thanks in advance for anyone's help on this matter as I know it takes your time and expertise. I am pretty new to SQL but learning my way through it just have an issue with a text to date field conversion. It is an Oracle 10g database and I am writing in SQL. There is a field called Demand which is formatted in varchar2 format of ddmmyy. There is also a field that is formatted as a date called Payment which is formatted as DD-MON-YYYY.
    Essentially I need to do a simple Payment >= Demand, however as you can see that is some issue with that being a varchar2 field. Does anyone know if it is possible to do that type of expression against those two fields. Was thinking about possibly converting the varchar2 to a date but not sure how to get to that DD-MON-YYYY format.
    Also there are situations where this Demand field will often times be null as it would have never recieved any outbound correspondence in the past and would not have a date at all.
    Thanks
    Edited by: user10860766 on Aug 18, 2009 8:14 AM
    Edited by: user10860766 on Aug 18, 2009 8:19 AM

    Hi,
    It's hard to detect bad dates in pure SQL, especially if you need to be precise about when February 29 is valid.
    It's easy with a user-define function, like the one in [this thread|http://forums.oracle.com/forums/thread.jspa?messageID=3669932&#3669932].
    Edited by: Frank Kulash on Aug 18, 2009 3:50 PM
    To create a stand-alone function:
    CREATE OR REPLACE FUNCTION     to_dt
    (     in_txt          IN     VARCHAR2                    -- to be converted
    ,     in_fmt_txt     IN     VARCHAR2     DEFAULT     'DD-MON-YYYY'     -- optional format
    ,     in_err_dt     IN     DATE          DEFAULT     NULL
    RETURN DATE
    DETERMINISTIC
    AS
    BEGIN
         -- Try to convert in_txt to a DATE.  If it works, fine.
         RETURN     TO_DATE (in_txt, in_fmt_txt);
    EXCEPTION     -- If TO_DATE caused an error, then this is not a valid DATE: return in_err_dt
         WHEN OTHERS
         THEN
              RETURN in_err_dt;
    END     to_dt
    /To use it:
    SELECT  primary_key  -- and/or other columns to identify the row
    ,       demand
    FROM    table_x
    WHERE   demand          IS NOT NULL
    AND     to_dt ( demand
               , 'DDMMYY'
               )          IS NULL;

  • Convert the date of string to datetime format 'MM/dd/yyyy' when the system date format is 'dd/MM/yyyy'.

    I need convert the date of string format 'MM/dd/yyyy' to datetime format 'MM/dd/yyyy' when the system date format is 'dd/MM/yyyy'.Since
    I need to search values based on date where my database datetime  is 'MM/dd/yyyy' format.

    In my opinion you should re-consider the assumption that the date picker returns a string. Maybe it is able to return a
    DateTime object directly instead of string. Then you will pass this value as a parameter of SQL query. This should work regardless of computer configuration.
    Otherwise, follow the previous string-based approaches.

  • Convert mm/dd/yyyy to this format dd/mm/yyyy

    Hi Gurus,
    How can I convert given this date format 10/19/2011 13:32:34 from my xml to this output dd/mm/yyyy hh:mm:ss?
    Need your help.
    Thank you
    Jayp
    Edited by: BIPnewbie on Jan 19, 2012 12:45 AM

    Thanks kavipriya for your response on this.
    Actually I was looking for similar kind of date conversion ....my xml date format is yy/mm/dd and need to convert to mm/dd/yyyy format...i tried regular format-date function but it didnt work.
    Now your function working fine ...
    Thanks a lot
    skat

  • JHS-00114: Date $CURRENT_DATE$ must be of format MM-dd-yyyy

    I am using jheadstart 10.1.2.2(build 32) in jdeveloper 10.1.2.1.0(build 1913).
    I need to display current date for a date field as a default value when inserting new rows.
    I set $CURRENT_DATE$ in default display value for that date field. The default value(todays date) is displayed only on a tabel(multi row insert is allowed) and on a form(single row insert) I get the above error JHS-00114: Date 2007-01-02 14:18:37.0 must be of format MM-dd-yyyy.
    The problem with multirow insert on a table even though it displays default value is user has to fill in other mandatory fields in the row since jheadstart thinks that user already started entering new row.
    It's ok for me if the default value is displayed properly on either table or form.
    Thanks for any help.
    Lavanya.

    Whenever you are in PM:
    sys@sid1> l
    1* select to_char(sysdate, 'MM/DD/YYYY HH12:MI:SS AM') from dual
    sys@sid1> /
    TO_CHAR(SYSDATE,'MM/DD
    07/09/2007 01:22:48 PM
    1 row selected.
    My time is 1:22:48 PM here. Even though I put AM in the to_char format, it noticed it was PM and changed it.

  • Date validation in "DD-MON-YYYY" Format,

    Hi ,
    I have created a textbox with date picker as (dd-mon-yyyy) .
    Now i want to create a validation on it for the format (dd-mon-yyyy) .
    I have created a pl/sql code with type "function returning error text".
    Begin
    If :P4_END_DATE IS NOT NULL THEN
    if :P4_END_DATE != to_date(:P4_END_DATE ,'DD-MON-YYYY') then
    return 'END DATE should be in "DD-MON-YYYY" Format';
    end if;
    END IF;
    End;
    When i type in like 20-NOV-08 it gives error as 'START DATE should be in "DD-MON-YYYY" Format',
    but when i change month like 20-11-2008 , it actually gives error
    ORA-01843: not a valid month
    Error ERR-1024 Unable to run "function body returning text" validation.

    Vaibss wrote:
    Hi ,
    I have created a textbox with date picker as (dd-mon-yyyy) .
    Now i want to create a validation on it for the format (dd-mon-yyyy) .
    I have created a pl/sql code with type "function returning error text".
    Begin
    If :P4_END_DATE IS NOT NULL THEN
    if :P4_END_DATE != to_date(:P4_END_DATE ,'DD-MON-YYYY') then
    return 'END DATE should be in "DD-MON-YYYY" Format';
    end if;
    END IF;
    End;
    When i type in like 20-NOV-08 it gives error as 'START DATE should be in "DD-MON-YYYY" Format',
    but when i change month like 20-11-2008 , it actually gives error
    ORA-01843: not a valid month
    Error ERR-1024 Unable to run "function body returning text" validation.The call to 'to_date' is raising an exception when it tries to convert your date, standard PL/SQL exception handling takes over and the rest of your code is ignored.
    You could try:
    declare
    pragma exception_init(invalid_date,-01830);
    l_dummy date;
    Begin
    If :P4_END_DATE IS NOT NULL THEN
    l_dummy := to_date(:P4_END_DATE ,'DD-MON-YYYY') then
    END IF;
    exception
    when invalid_date then
    return 'END DATE should be in "DD-MON-YYYY" Format';
    End;
    but even that will not check that the user actually used your desired format - the to_date can be quite flexible e.g. accepting separators other than the '-' that you have declared. In fact, the above would only catch the user entering a 'date' that is shorter than the format string - changing the 'invalid_date' for 'others' would capture more (all!) exceptions.
    You probably want to look at using regular expressions to perform the format validation.
    Edited by: Andy Hardy on Nov 25, 2008 12:29 PM

  • How to add date in MM/DD/YYY  format at the end of a string

    Hi
    I want Description to look like
    ' PARTICIPATION ON TEMPORARY TV SHOW EXPIRING ' and include the "latest show expiration date" as "MM/DD/YYYY"
    Pls help ......
    try {
                            Date date= new Date();
                             System.out.println("THE TODAYS DATE is :"+date);
                               DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    //                         DateFormat df = new SimpleDateFormat("MM/DD/YYYY");   -----> Its not allowing this format ????????
                             begin_Date = hashDateE.get(id);
                             System.out.println("THE LATEST TV SHOW DATE is :"+begin_Date);
                             Date d1 = df.parse(begin_Date);
                             String relation;
                             if(d1.equals(date))
                                  relation = "both the dates are same";
                             else if(d1.before(date))
                                  relation = "BEFORE";
                             else
                                  relation = "AFTER";
                             //System.out.println(d1 + "is" + relation + ' ' + date);
                             if("10".equals(latestShow)){
                              if("BEFORE".equals(relation)){
                                   System.out.println("The latest show date is expired");
                              Code =3;
                              Description = "PARTICIPATION ON TEMPORARY TV SHOW EXPIRED ";
                              else if("AFTER".equals(relation)) {
                                   System.out.println("The latest show date is non expired");
                                  Code = 2;
                                   Description = "PARTICIPATION ON TEMPORARY TV SHOW EXPIRING" + d1; -------------> I TRIED THIS WAY ( d1 should be in this format MM/DD/YYY
                              }else {
                                   System.out.println("The latest show date is non expired");
                                 Code = 20;
                                  Description = "PARTICIPATION ON TEMPORARY TV SHOW EXPIRING" + d1;
                        

    If you have a string like 2008-12-15 and you want to interpret it as a date and format it as 12/15/2008, then you need two DateFormat objects.
    One to parse the String in the first format into a Date, -------> i could do this
    try {
              String begin_date = "2008-12-15";
              System.out.println("The begin date is :"+begin_date);
              DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
              Date d1 =  df.parse(begin_date);
              System.out.println("the Date value is d1 :"+d1);
    catch() {
    }Output is :The begin date is :2008-12-15
    the Date value is d1 :Mon Dec 15 00:00:00 EST 2008
    Pls help me with the second part :- ?????/
    and one to format that Date into a String in the second format. MM/dd/yyyy --- how to do this ..after i tried several times with different statements , i am asking this piece of code to achieve this

  • Date validation in " DD-MON-YYYY"

    Hi ,
    I have created a textbox with date picker as (dd-mon-yyyy) .
    Now i want to create a validation on it for the format (dd-mon-yyyy) .
    I have created a pl/sql code with type "function returning error text".
    Begin
    If :P4_END_DATE IS NOT NULL THEN
    if :P4_END_DATE != to_date(:P4_END_DATE ,'DD-MON-YYYY') then
    return 'END DATE should be in "DD-MON-YYYY" Format';
    end if;
    END IF;
    End;
    When i type in like 20-NOV-08 it gives error as 'START DATE should be in "DD-MON-YYYY" Format',
    but when i change month like 20-11-2008 , it actually gives error
    ORA-01843: not a valid month
    Error ERR-1024 Unable to run "function body returning text" validation.
    Edited by: Vaibss on Nov 25, 2008 2:09 AM
    Edited by: Vaibss on Nov 25, 2008 2:10 AM

    Hello,
    Duplicate post -
    Date validation in "DD-MON-YYYY" Format,
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • Validating a text field that has date in the format mm/dd/yyyy

    How can I validate a text field such that it should be in the format mm/dd/yyyy and it should not be greater that a particular date.
    for example the date I enter should not be greater than 01/01/2007

    What you can do is use the SimpleDateFormat class to try and parse the text date into a Date object like this:
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    Date mydate = sdf.parse(textdate);if that fails than the date has the wrong format (you'll get a ParseException if I'm not mistaken).
    The next step is to create a Date for 1/1/2007 and then do a date compare between your two dates. You can create a date yourself using the Calendar class.

  • Convert AS400 integer number to a date format MM/DD/YYYY

    Hi
    I need a formula for converting AS400 numeric date that is in this format 1110101 CYYMMDD to this format 01/01/2011
    I am using crystal reports 2008
    Thanks Fred

    This should do the trick...
    Local StringVar x := ToText({@AC Date}, "0");
    Local NumberVar c := (ToNumber(LEFT(x, 1)) + 1) * 10;
    x := RIGHT(x, 6);
    Local NumberVar y := ToNumber(ToText(c, "0") & LEFT(x, 2));
    x := RIGHT(x, 4);
    Local NumberVar m := ToNumber(LEFT(x, 2));
    x := RIGHT(x, 2);
    Local NumberVar d :=ToNumber(x);
    Dateserial(y,m,d)
    HTH,
    Jason

  • Problem in date formatting DD-MMM-YYYY

    Hi,
    I am writing a method in my Application:
    //@@begin FormatDate()
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
         Date d;
         String OutDate = "";
         try {
              d = dateFormat.parse(InDate);
              dateFormat.applyPattern("DD-MMM-YYYY");
              OutDate = dateFormat.format(d);
         } catch (ParseException e) {
              wdComponentAPI.getMessageManager().reportWarning("Date Parse Exception");
         return (OutDate);
        //@@end
    The OutDate that I get is in Format DD-MMM-YYYY but MMM is in digits instead of letters i.e. for 2007-07-31 it gives 31-007-2007 instead of 31-Jul-2007.
    Any clues to get proper output??
    I have tried applying format DD-MON-YYYY it too doesn't help.
    Thanks
    Anagha

    Hi ..
    check this link..
    https://help.sap.com/javadocs/NW04/current/wd/com/sap/tc/webdynpro/services/sal/localization/api/IWDResourceHandler.html
    https://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/services/sal/localization/api/IWDResourceHandler.html#formatDate(java.util.Date)
    How to calculate next date in Java
    Re: Problem with DATE field
    Hope this will helpful for u..
    Urs GS

  • Editable and Read-Only Date Picker have different display formats -- Bug?

    Hi all,
    This is a follow on to a previous posting about getting a Date Picker field to display read-only (Date Picker and Read-Only Condition works on LAST state of element
    Now past that hurdle, I have noticed something about the date picker field when it is displays read-only. Namely, the date format is not the format selected, nor does the read-only date format comply with the format mask in the source section.
    I've modified my small test app to work as intended in order to demonstrate this feature. I also opened it up so everyone can see it <blush>. You can find it here: http://htmldb.oracle.com/pls/otn/f?p=42513: Please navigate to the Update Project tab.
    When a project in Program One through Four is selected (which has a Spec Committed date), the date is displayed DD-MON-YY format. When a project the other Programs (which do not have Spec Committed dates at the time of this writing) are selected, and a date value selected with the date picker, the date is displayed in the anticipated DD-MON-YYYY format.
    Anyone else notice this, or have I just missed something obvious?
    Thanks,
    Petie

    I'm not sure why this happens but to work around it I added this before header process code to the page:
    execute immediate 'alter session set nls_date_format = ''DD-MON-YYYY''';
    Scott

  • Converting Date Column to format MM/DD/YYYY in RPD

    Hi all,
    I have a requirement like converting a Date column to format MM/DD/YYYY in RPD. Any help as we are not supposed to use the BI Answers Data Fomat for showing this format.
    Thankyou,
    Edited by: [email protected] on May 10, 2010 11:49 PM

    Hi Saichand,
    I need the resulting column in DATE format only. The solution which you specified converts the datatype to character. Is there anyway to convert the format but not the datatype.

Maybe you are looking for