Handle Date format in a dynamic way

Hi Experts,
I need to handle the date format in a dynamic way in different systems.
Sample Scenario:
In my DEV system i am writing a select query where i need to validate the date field which is of the format 12/31/9999.
select * from <table> where date = '12/31/9999'.
This gets relevant records & works fine in DEV system.
But when it goes to QA system the same select query fails to fetch data as the date format is 12.31.9999.
select * from <table>
where date = '12/31/9999'. --> Fails
Similarly when it is PRD system (production) the same select query fails as the date format is 12-31-9999.
select * from <table>
where date = '12/31/9999'. --> Fails
Please post your suggestions.
Thanks
Dany

If you are looking at the date from SE16, or some other output screen, dates are converted to what is referred to as external format. But when they are stored, they are stored in internal format which is always YYYYMMDD. So when you are doing a SELECT from database table using a date field in your WHERE clause, you have to use internal format of the date (YYYYMMDD). When you output a date that you extracted onto a screen using WRITE statement, it will be converted to external format depending on user format specifications. But the date will be in internal format within your program, so if you are transferring a date from the database directly to a file, you are transferring it as YYYYMMDD. If you need it in external format, then you have to use WRITE...TO... option. See help on WRITE command.

Similar Messages

  • Streams Conflict Handler Date Format

    Hi.
    Into my Conflict Handler PL/SQL I have this instruction:
         tmp := lcr.get_value('NEW','DT_ULT_VERIFICACAO'); rc := tmp.getDATE(v_DT_ULT_VERIFICACAO);
         IF (v_DT_ULT_VERIFICACAO is not null) THEN
         cmdupd := cmdupd||',DT_ULT_VERIFICACAO='||'TO_DATE('''||v_DT_ULT_VERIFICACAO||''','''||'DD/MM/RR'||''')'; END IF;
    The result after execution is:
    UPDATE HW_ITENS SET USER_UNF_ID=13,CD_ITEM=4,NR_INMETRO=32037347,NR_SERIE='ME - 0295',
    DT_ULT_VERIFICACAO=TO_DATE('04-DEC-09','DD/MM/RR'),NR_ULT_VERIFICACAO=21036627,TP_ULT_RESULTADO=4
    WHERE ITM_ID = 2836955 and SRV_UNF_ID = 13
    As we can see, I received a date format of DD/MON/AA. This is not good to my work. I need a date format of DD/MM/AA.
    How can I change this when using a Apply Conflict Handler ?
    Thank in advance.
    JoseFormiga

    Did you checked the setting of the database NLS_DATA_FORMAT if the column was date or NLS_TIMESTAMP_FORMAT for timestamp.
    Check the setting of V$NLS_PARAMETERS.
    set pages 66 lines 190
    SQL> select * from V$NLS_PARAMETERS
    PARAMETER                                                        VALUE
    NLS_LANGUAGE                                                     AMERICAN
    NLS_TERRITORY                                                    AMERICA
    NLS_CURRENCY                                                     $
    NLS_ISO_CURRENCY                                                 AMERICA
    NLS_NUMERIC_CHARACTERS                                           .,
    NLS_CALENDAR                                                     GREGORIAN
    NLS_DATE_FORMAT                                                  DD-MON-RR
    NLS_DATE_LANGUAGE                                                AMERICAN
    NLS_CHARACTERSET                                                 AL32UTF8
    NLS_SORT                                                         BINARY
    NLS_TIME_FORMAT                                                  HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT                                             DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT                                               HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT                                          DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY                                                $
    NLS_NCHAR_CHARACTERSET                                           AL16UTF16
    NLS_COMP                                                         BINARY
    NLS_LENGTH_SEMANTICS                                             CHAR
    NLS_NCHAR_CONV_EXCP                                              FALSE

  • Handling Date Format

    Hi Everyone,
    I am using DB 11g and Apex 4.1 Versions.
    We are working on a project where most of the time we would be uploading CSV through Apex and store the data in DB using some procedures developed by us and most of the time we get different date formats in the CSV which is sent by the client. It is the major issue which i encounter in my carrer.
    Please suggest me how we can handle or tell the procedure to check if one format doesn't work take another if that also doesn't work go for another.
    Any link or code or anything Please help me with this and make my career a bit more easy :)
    Thanks,
    Shoaib

    Hi, Shoaib,
    Shoaib581 wrote:
    Thanks Guys,Pay particular attention to Paul's reply. The people who enter the data are the best people to make sure it is correct. Do whatever you can to ensure valid, consistent data entry. It may be hard for users who want to use their own favorite format, but not as hard as it is to correct mistakes later.
    >
    >
    Your clarification really helped me and made many things clear for me :). Any suggestion, how we can handle if the date format comes in below formats,
    DD-MM-YY OR DD-MON-YY formats. Oracle forgives you if you use 'MON' where 'MM' was expected, so
    TO_DATE ( '1-Dec-2012'
            , 'DD-MM-YYYY'
            )returns Decemer 1, 2012: it WILL NOT raise an error.
    The converse is not true: TO_DATE (str, 'DD-Mon-YYYY') WILL raise an error if you the month part is '12'.
    Here's a package function I wrote to try various formats in turn:
    --          **   t o _ d t   **
    --     to_dt attempts to convert in_txt to a DATE using in_fmt_1_txt.
    --     If that fails, it tries again, using in_fmt_2_txt.
    --     If that fails, it tries again, using in_fmt_3_txt, and so on.
    --     As soon as one conversion works, the function returns the DATE,
    --     and the remaining formats are not tried.
    --     If all the formats given fail, then in_default_dt is returned.
    FUNCTION     to_dt
    (     in_txt          IN     VARCHAR2                    -- string to be converted
    ,     in_fmt_1_txt     IN     VARCHAR2     DEFAULT     'DD-Mon-YYYY'     -- 1st format to try
    ,     in_fmt_2_txt     IN     VARCHAR2     DEFAULT NULL          -- 2nd format to try
    ,     in_fmt_3_txt     IN     VARCHAR2     DEFAULT NULL          -- 3rd format to try
    ,     in_fmt_4_txt     IN     VARCHAR2     DEFAULT NULL          -- 4th format to try
    ,     in_fmt_5_txt     IN     VARCHAR2     DEFAULT NULL          -- 5th format to try
    ,     in_default_dt     IN     DATE          DEFAULT     NULL          -- Returned if nothing works
    RETURN     DATE
    DETERMINISTIC
    IS
         fmt_cnt          PLS_INTEGER     := 5;          -- Number of in_fmt_ arguments
         fmt_num          PLS_INTEGER     := 1;          -- Number of argument being tried
         return_dt     DATE           := NULL;     -- To be returned
    BEGIN
         FOR  fmt_num  IN  1 ..  fmt_cnt
         LOOP
              BEGIN     -- Block to trap conversion errors
                   return_dt := TO_DATE ( in_txt
                                       , CASE     fmt_num
                                              WHEN  1     THEN  in_fmt_1_txt
                                              WHEN  2     THEN  in_fmt_2_txt
                                              WHEN  3     THEN  in_fmt_3_txt
                                              WHEN  4     THEN  in_fmt_4_txt
                                              WHEN  5     THEN  in_fmt_5_txt
                                    END
                   -- If control reaches this point, then TO_DATE worked
                   RETURN     return_dt;
              EXCEPTION
                   WHEN OTHERS
                   THEN
                        IF  SQLCODE  BETWEEN -1865
                                      AND     -1839
                        THEN
                                NULL;
                        ELSE
                             RAISE;
                       END IF;
              END;     -- Block to trap conversion errors
         END LOOP;
         RETURN     in_default_dt;
    END     to_dt
    ;Once again, this will convert a string like '12/11/10' to a DATE. It will not necessarily return the same DATE that was meant by whoever entered the string.

  • Numbers App - .xls Imported Date Format

    Hi,
    I've just installed Numbers on IOS 7 (IPAD2) and have imported an .xls 97 file. All is good except the dates which have been imported as serial numbers e.g. 1/12/2013 appears as 41609. I have tried formatting the cells as date with any of the variations of the "5 Jan etc" example yet the number remains. The only way I can correct them is to re-enter them manually. The regional (UK) settings for the Ipad are correct so I'm not sure what's causing this, or what it is I've missed - any advice greatly appreciated. Thank you.

    No expereince with LibreOffice, so I can't address how it handles date formating. Its sounds a little like it is still including the time sets and storing them using using a string that Numbers can't convert (and Excel does recognize), but I'm just guessing.
    This might provide a clue: https://help.libreoffice.org/Calc/Date_and_Time_Functions. or at least a starting point for your research.

  • Date Format in Record Selection

    Hello,
    I have a problem where the Crystal Report is not returning all the rows that meet the record selection criteria because I believe there is a problem with the date format.
    My record selection criteria is:
    ( {EMPOS.POS_STARTC} <= {@EB_EDATE} and {EMPOS.POS_ENDD} >= {@EB_SDATE} ) or
        IsNull({EMPOS.POS_ENDD} )
    where EB_EDATE and EB_SDATE are formula fields with the values Date(2011, 12, 31) and Date(2011, 01, 01) respectively which returns the format of DD/MM/YYYY used by the FinanceOne (F1) ERP application that we run the report from.  Both formula fields are overriden by the run parameters in the same date format in F1.
    If I were to run the SQL below in a query tool like Toad, it returns a row where pos_startc is 1/01/2011 and pos_endd is null, that is not included in the report.
    select * from empos where det_numbera = '01285'
                          and ( (pos_startc <= '20111231' and pos_endd >= '20110101') or pos_endd is null )
    1. Why is Crystal Reports excluding this row when the date format is different?
    2. How can I change the criteria (or format) to include the one of many other rows missing?

    Hello,
    Crystal Reports is now returning all rows where pos_endd is null in the database with the record selection criteria of:
    {CHRIS_EmpSal.pos_endd} = date(0, 0, 0)
    However, when I run it in Finance One, it doesn't like this date format   Is there another way to get both Crystal and Finance One (i.e., SQL Server DB) to recognise the same syntax for null dates?

  • Date Format in Record Working Time

    Dear All,
    We are using standard ESS SAP Application i.e. Record Working Time. In this application in Weekly View, the date format is MM.DD.YYYY.
    But for other countries it should be DD.MM.YYYY.
    How to change this format?
    We have changed the format in SU3 but still from portal the format is same.
    Please help.
    Regards,
    Nikesh Shah

    Hello,
    Crystal Reports is now returning all rows where pos_endd is null in the database with the record selection criteria of:
    {CHRIS_EmpSal.pos_endd} = date(0, 0, 0)
    However, when I run it in Finance One, it doesn't like this date format   Is there another way to get both Crystal and Finance One (i.e., SQL Server DB) to recognise the same syntax for null dates?

  • Problem in Date Format when user chages the date format in preferences

    I want to generalize my code so that user can change what ever Date format he wants, I will get the date from the page in the format yyyy-mm-dd, and if the Date Format is
    set to MM/dd/yyyy in prefernces i need to use MM/dd/yyyy and if the Date Format is set to dd-Mon-yyyy in prefernces i need to use dd-MMM-yy, so my question is how to know what Date format is set in the preference so that i can have all the possible date format for inserting the date
    Thanks
    Babu

    Babu,
    The date format in OAF Pages is controlled by profile ICX: Date format mask.This profile can be set at site as well as user level for the individual users to set the Date format.
    But I would advice not to go for setting different profile values at user level, because i remember some old threads, where seeded Oracle pages fail, as code their is not generalised to handle date formats.
    If your are planning to have this in ur custom page, go ahead, but do check the entire flow is working fine for different values of this profile at user level.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Date Format IN BDC

    Hi,
    In One Interview I was asked that How can You Handle Data Format when Writing BDC ?

    Satya,
    The date format depends on User settings. Its different for different login ID's.
    It can be YYYY.MM.DD or MM.DD.YYYY or anything.
    To handle the date format, you need to query on table USR01 and fetch DATFM field that stores date format.
    Refer below piece of code
    */...Fetch the date format settings for the user
          SELECT SINGLE datfm
                   INTO gv_date_format
                   FROM usr01
                  WHERE bname = sy-uname.
      CASE gv_date_format.
        WHEN 1.     "DD.MM.YYYY
          CONCATENATE fv_impdate+6(2) '.'
                      fv_impdate+4(2) '.'
                      fv_impdate+0(4) INTO fv_expdate.
        WHEN 2.     "MM/DD/YYYY
          CONCATENATE fv_impdate+4(2) '/'
                      fv_impdate+6(2) '/'
                      fv_impdate+0(4) INTO fv_expdate.
        WHEN 3.     "MM-DD-YYYY
          CONCATENATE fv_impdate+4(2) '-'
                      fv_impdate+6(2) '-'
                      fv_impdate+0(4) INTO fv_expdate.
        WHEN 4.     "YYYY.MM.DD
          CONCATENATE fv_impdate+0(4) '.'
                      fv_impdate+4(2) '.'
                      fv_impdate+6(2) INTO fv_expdate.
        WHEN 5.     "YYYY/MM/DD
          CONCATENATE fv_impdate+0(4) '/'
                      fv_impdate+4(2) '/'
                      fv_impdate+6(2) INTO fv_expdate.
        WHEN 6.     "YYYY-MM-DD
          CONCATENATE fv_impdate+0(4) '-'
                      fv_impdate+4(2) '-'
                      fv_impdate+6(2) INTO fv_expdate.
      ENDCASE.
    This would convert the date into the format set for user.
    Hope this is helpful.
    Amogh

  • SQL DATE FORMATS INTERCHANGED

    Hi ,
    Pls find below details abt the issue:
    one of the column in a tablecontains date format in 2 different ways.
    acct_create_date column is varchar2 datatype
    acct_create_date 20041231093030 yyyymmddhhmiss
    20041030162525
    28281230112004 ssmihhddmmyyyy
    24241028102004
    these r the two different formats a column contains in a table. our objective is to get all the dates to consistent format like
    yyyymmddhhmiss.
    can anyone suggest ways to do it ...
    Thanks in advance

    I hope that the intention is to convert the column into a date datatype, so you won't have to go through this pain again!
    Is there another column which determines what format the date is in, or can be used to derive the format?
    If I were you, I'd knock up two functions, one for each format, and use that to test each result to see if it will successfully convert to a date or not. That way, the majority should be easy to spot which format they're in, and hopefully only a few will be dates in both formats - you'd have to go through those cases manually to see if you can work out what the format should be. You'd also have to limit the range of years in your function.
    eg.
    select date_col, to_ymdhms(date_col), to_smhdmy(date_col)
    from my_tab
    where to_ymdhms(date_col) is not null
    and to_smhdmy(date_col) is not null;

  • Date Formatting in Charts and Dynamic column resizing in Cross tabs

    Hi All,
    I am new to Design Studio, so am in desperate need of your help on the following:
    Is there a way we can change the date format in x axis in charts?
    For ex: Am getting dates as mm/yyyyy from BW but requirement is to show in yy-Mon
    Requirement is to display data in cross tab just below the charts. How can I make the column widths in the cross tab the same as x-axis divisions in the chart? Also, this will be dynamic as depending on filter selection x axis scaling in charts will vary.
    In cross tab, can I hide the column header?
    Would really appreciate any kind of help from you.
    Thanks & Regards
    Swasti

    HI Swasti,
    To answer your first question, in Design Studio it's what you see is what you get! so it shows the Data Labels as it is in the BEx output, if you have to modify this you have to change it in the Background.
    There might be CSS workarounds, but I am not sure if that will satisfy your requirements.
    You can fix the Column width, but it would be constant, aligning that to your X-axis would require a lot of Effort.
    You cannot hide the Column header directly, but one workaround would be to use a white BG text component to overlay on the Crosstab.
    Regards,
    Fazith Ali Z

  • How to handle Multiple date formats for the same date field in SQL*Loader

    Dear All,
    I got a requirement where I need to get data from a text file and insert the same into oracle table.
    I am using SQL*Loader to populate the data from the text file into my table.
    The file has one field where I am expecting date date data in multiple formats, like dd/mon/yyyy, yyyy/dd/mon, yyyy/mon/dd, ,mm/dd/yyyy, mon/dd/yyyy.
    While using SQL*Loader, I can see Loading is failing for records where we have formats like yyyy/dd/mon, yyyy/mon/dd, mon/dd/yyyy.
    Is there any way in SQL*Loader where we can mention all these date formats so that this date data should go smoothly into the underlying date column in the table.
    Appreciate your response on this.
    Thanks,
    Madhu K.

    The point being made was, are you sure that you can uniquely identify a date format from the value you receieve? Are you sure that the data stored is only of a particular limited set of formats?
    e.g. if you had a value of '07/08/03' how do you know what format that is?
    It could be...
    7th August 2003 (thus assuming it's DD/MM/RR format)
    or
    8th July 2003 (thus assuming it's MM/DD/RR format)
    or
    3rd August 2007 (thus assuming it's RR/MM/DD format)
    or
    8th March 2007 (thus assuming it's RR/DD/MM format)
    or even more obscurely...
    3rd July 2008 (MM/RR/DD)
    or
    7th March 2008 (DD/RR/MM)
    Do you have any information to tell you what formats are valid that would allow you to be specific and know what date format is meant?
    This is a classic example of why dates should be stored on the database using DATE datatype and not VARCHAR2. It can lead to corruption of data, especially if the date can be entered in any format a user wishes.

  • Dynamic date format in a VO

    Hi All
    Jdev 11.1.1.6.0.
    I have a query based VO with an attribute named date range which is a concatenation of two dates (SELECT DATE1||' - '||DATE2 as date_range
    FROM xyz)
    date_range is a display only field in UI.
    I want to apply different date formats(individually on DATE1/DATE2 and then show the concatenation) based on the user logged on.
    Is there a way I could achieve this at VO level itself because at UI level it doesn't look feasible to apply a af:convertDateTime pattern ="<mydatepattern">
    If it could be done at UI level also, I'll appreciate pointers.
    Thanks a lot

    our online doc would be a good place to start. try...
    http://htmldb.oracle.com/i/doc/mvl_api.htm#sthref1316
    ...for instance.
    regards,
    raj

  • How can I dynamically change the Application Date Format?

    Hi everyone...
    In my application (v 3.2) I let the user set the application date format dynamically through a "preference" value they can change on the go.
    I then take the format they pick and assign their value (ie: DD-MON-YYYY) and pad 'HH:MI' to it and use this as the PICK_DATE_FORMAT_MASK which works great for most date pickers.
    The problem I have is that some date picker I use in the application don't require the HH:MI, they simply need the DD-MON-YYYY part. Could I use the NLS_DATE_FORMAT for this? Would I then be able to use date pickers with the "use application date format"? It doesn't seem to work for me.
    In other words, I basically need 2 date formats for my application date pickers; 1 for simply the dates and 1 for dates including time. And these 2 formats are chosen by the user by setting an application preference dynamically at run time.
    Not sure if I make sense here....any idea?
    Thanks!
    Francois

    "use application date format" is the choice you want.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • Dynamic date formatting

    Is there a function module or some other method (in 4.6C) that can write a date in a format supplied dynamically? I searched in SE37 but I don't find what I'm looking for and most of them aren't documented
    I know of the addition to the write command, but it seems there you have to hardcode them - it's not what I'm looking for.

    Hi,
    using CONVERSION_EXIT_PDATE_output
    or output we convert date format.
    and also using SET DATE MASK  u can convert date format .
    after display that .
    if use full reward points.

  • Settng Data Format Dynamically

    Hi All,
    How to set the data format to a column dynamically?
    I have a column, which displays Amount, in a Request. For this Column, I have chosen 'Override Default Data Format' and set the 'Decimal Places' to 2.
    But, for some Reports I need to display the Amount without any decimal places viz., 1234.00 ---> 1234.
    How can I do this?
    Thanks in Advance,
    -Vency

    You'd apply the formatting in the Business Model and Mapping layer - and then drag the columns into the Presentation layer.
    Right mouse click the source column, click 'duplicate'. Select the duplicated column (call it what you want) click properties, and from the data type tab edit the mapping applying any format expression you want.
    The other alternative is to do it in the physical layer, most of my base objects are database views so I could just add the extra column in there.

Maybe you are looking for

  • 24" iMac Video Card difference

    Hello, Is there a noticeable difference between the NVidia 128mgs and 256mgs cards - specifically while gaming - as to how the graphics show on the screen? Thanks. Jen

  • Which iPad 4 should I buy if I live outside the US and I want wifi   Celullar

    I want to buy the new ipad from apple.com, i live outside the US, which carrier should i select to work celullar outside the us? or do i need to buy one factory unlocked? thx...

  • Convert Excel into Password Protected PDF Files

    Hello Aandi/Lenoard, I believe you are the Adobe Forums administrators so I thought you guys are the right people to approach. OTHERS ARE ALSO INVITED TO COMMENT ON THIS TOPIC. I have C# desktop app which generates Excel files and our goal is to conv

  • Flex Dashboard and Using Flex in a Portal Environment

    Hello I am looking to develop Flex dashboard and use Flex in a Portal environment. If you any thoughts or information, kindly let me know or some insight. Thanks and regards

  • IPod Nano data recovery

    Hi. I own an iPod Nano, and yesterday, I accidentally dropped it into a sink. It flashed a message about firewire connections and prompty shut off. Now, I tried to turn it on, about 5 times, and plugged it in once, so it's probably gone. But here's m