Query regarding Date Function

All,
Can I know the difference between the following two queries
select TO_CHAR(TRUNC(sysdate),'dd-mon-rr') from dual;
select TO_CHAR(TRUNC(sysdate),'dd-mon-yy') from dual;
However, both the query gives the same result as '03-nov-09'.
Regards
ND

...of which century?
SQL> var dt varchar2(10)
SQL>
SQL> begin
  2     :dt := '03-11-51';
  3  end;
  4  /
PL/SQL procedure successfully completed.
SQL>
SQL> select TO_CHAR(to_date (:dt, 'dd-mm-rr'),'dd-mon-yyyy') from dual;
TO_CHAR(TO_DATE(:DT,
03-nov-1951
SQL>
SQL> select TO_CHAR(to_date (:dt, 'dd-mm-yy'),'dd-mon-yyyy') from dual;
TO_CHAR(TO_DATE(:DT,
03-nov-2051Don't use a two digit year...

Similar Messages

  • A query regarding synchronised functions, using shared object

    Hi all.
    I have this little query, regarding the functions that are synchronised, based on accessing the lock to the object, which is being used for synchronizing.
    Ok, I will clear myself with the following example :
    class First
    int a;
    static int b;
    public void func_one()
    synchronized((Integer) a)
    { // function logic
    } // End of func_one
    public void func_two()
    synchronized((Integer) b)
    { / function logic
    } // End of func_two
    public static void func_three()
    synchronized((Integer) a)
    { // function logic
    } // End of func_three, WHICH IS ACTUALLY NOT ALLOWED,
    // just written here for completeness.
    public static void func_four()
    synchronized((Integer) b)
    { / function logic
    } // End of func_four
    First obj1 = new First();
    First obj2 = new First();
    Note that the four functions are different on the following criteria :
    a) Whether the function is static or non-static.
    b) Whether the object on which synchronization is based is a static, or a non-static member of the class.
    Now, first my-thoughts; kindly correct me if I am wrong :
    a) In case 1, we have a non-static function, synchronized on a non-static object. Thus, effectively, there is no-synchronisation, since in case obj1 and obj2 happen to call the func_one at the same time, obj1 will obtain lock for obj1.a; and obj2 will obtain lock to obj2.a; and both can go inside the supposed-to-be-synchronized-function-but-actually-is-not merrily.
    Kindly correct me I am wrong anywhere in the above.
    b) In case 2, we have a non-static function, synchronized on a static object. Here, again if obj1, and obj2 happen to call the function at the same time, obj1 will try to obtain lock for obj1.a; while obj2 will try to obtain lock for obj2.a. However, since obj1.a and obj2.a are the same, thus we will indeed obtain sychronisation.
    Kindly correct me I am wrong anywhere in the above.
    c) In case 3, we have a static function , synchronized on a non-static object. However, Java does not allow functions of this type, so we may safely move forward.
    d) In case 4, we have a static function, synchronized on a static object.
    Here, again if obj1, and obj2 happen to call the function at the same time, obj1 will try to obtain lock for obj1.a; while obj2 will try to obtain lock for obj2.a. However, since obj1.a and obj2.a are the same, thus we will indeed obtain sychronisation. But we are only partly done for this case.
    First, Kindly correct me I am wrong anywhere in the above.
    Now, I have a query : what happens if the call is made in a classically static manner, i.e. using the statement "First.func_four;".
    Another query : so far we have been assuming that the only objects contending for the synchronized function are obj1, and obj2, in a single thread. Now, consider this, suppose we have the same reference obj1, in two threads, and the call "obj1.func_four;" happens to occur at the same time from each of these threads. Thus, we have obj1 rying to obtain lock for obj1.a; and again obj1 trying to obtain lock for obj1.a, which are the same locks. So, if obj1.a of the first thread obtains the lock, then it will enter the function no-doubt, but the call from the second thread will also succeed. Thus, effectively, our synchronisation is broken.
    Or am I being dumb ?
    Looking forward to replies..
    Ashutosh

    a) In case 1, we have a non-static function, synchronized on a non-static object. Thus, effectively, there is no-synchronisationThere is no synchronization between distinct First objects, but that's what you specified. Apart from the coding bug noted below, there would be synchronization between different threads using the same instance of First.
    b) In case 2, we have a non-static function, synchronized on a static object. Here, again if obj1, and obj2 happen to call the function at the same time, obj1 will try to obtain lock for obj1.a; while obj2 will try to obtain lock for obj2.a.obj1/2 don't call methods or try to obtain locks. The two different threads do that. And you mean First.b, not obj1.b and obj2.b, but see also below.
    d) In case 4, we have a static function, synchronized on a static object. Here, again if obj1, and obj2 happen to call the function at the same time, obj1 will try to obtain lock for obj1.a; while obj2 will try to obtain lock for obj2.a.Again, obj1/2 don't call methods or try to obtain locks. The two different threads do that. And again, you mean First.b. obj1.b and obj2.b are the same as First.b. Does that make it clearer?
    Now, I have a query : what happens if the call is made in a classically static manner, i.e. using the statement "First.func_four;".That's what happens in any case whether you write obj1.func_four(), obj2.func)four(), or First.func_four(). All these are identical when func_four(0 is static.
    Now, consider this, suppose we have the same reference obj1, in two threads, and the call "obj1.func_four;" happens to occur at the same time from each of these threads. Thus, we have obj1 rying to obtain lock for obj1.aNo we don't, we have a thread trying to obtain the lock on First.b.
    and again obj1 trying to obtain lock for obj1.aYou mean obj2 and First.b, but obj2 doesn't obtain the lock, the thread does.
    which are the same locks. So, if obj1.a of the first thread obtains the lock, then it will enter the function no-doubt, but the call from the second thread will also succeed.Of course it won't. Your reasoning here makes zero sense..Once First.b is locked it is locked. End of story.
    Thus, effectively, our synchronisation is broken.No it isn't. The second thread will wait on the same First.b object that the first thread has locked.
    However in any case you have a much bigger problem here. You're autoboxing your local 'int' variable to a possibly brand-new Integer object every call, so there may be no synchronization at all.
    You need:
    Object a = new Object();
    static Object b = new Object();

  • " Query regarding Data transfer from Bi to BO Tool "

    Dear Friends,
                       I am having a query. I have  created a Info-cube and established the universe on the top of the Info-cube.The Dat is coming in the Bi system. When I created a new Webi-report the Data from the ino-cube in the universe is not reflecting the Webi-report .
                         Can anyone tell me the solution for the Data Load in the Webi-report .

    Hi,
    There are two ways to design universe on top of cube/Query.
    1)Olap Universe :Please go through by below link for how to create mdx universe.by this way create one connection and select cube or query and by default designer will replicate cube/query in the universe.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/903a7fc7-19e8-2d10-fa95-b050de946b61?quicklink=index&overridelayout=true
    2) Create Data federator project on top of Cube and then design universe.
    To pull data in the webi report create universe then  select objects and run the query.If data is available in the cube or query that will come in the webi report.
    I have already said webi report pull data at run time.there is no need or no way to load data in the universe or webi.
    Design a universe and create  webi or deski report on top of universe.
    For more information you can search on net can be found documents how to create report.
    Hope this helps you.
    Thanks,
    Amit

  • Query regarding Min function with Date

    Dear All,
    I have written query as follows but it is giving me error message.
    Selection CityCode, CityName, Min(Date)
    from Entry
    I want to write a query which should generate minimum date of transactions of city. There are about 50 cities in the Entry table and against each city there are thousands of records, I want to display only the oldest date against each city with its code. In the out put there should 50 rows as there are 50 cities and oldest (min) date. Can any one please help on this SQL.
    Thanks

    Do you want just min date in the table or need grouping by citycode and city name also?
    If just min date of the table is needed, use row_number analytic function to get the min date in the table.

  • Problem regarding data function 'SUMGT' (Overall Result) in BEx query desig

    Hi,
    I have created one query where I want to see the inventory data month wise. That's why at first I have placed 0calmonth (with variable) in column, secondly kept all the key figures which I want to see month wise under one structure, then placed the structure under 0calmonth in column. Now in that structure I have one key figure like 'total stock' and another global calculated key figure '% of total inventory' (='total stock' <b>%A</b> <b>SUMGT</b> 'total stock').
    Now the problem is when ever I'm giving the value of month from 02.2006 to 05.2006, it is calculating the value of '% of total inventory' for every month with respect to the overall result of 'total stock' for month 05.2006. 
    But I want to calculate the value of '% of total inventory' for each month with respect to the overall result of 'total stock' for corresponding month.
    Please suggest what I'll do now.
    Thanks,
    Arijit.

    Hi,
    now i got whats the issue is.
    Check aggregation properties of 'total stock'(RSD1>provide tech name of total stock>display-->aggragation tab)...
    Exception aggregation would have been set to <b>'Last Value'</b> with some time char as aggregation ref characteristic..
    That is the reason why  SUMGT (or %SUMGT) is calculating on Last value of the 0calmonth interval.
    i.e if you provide 02.2006 to 07.2006, %of total inventory for every month would be with respect to value of 07.2006...
    Hope this helps...
    Dont forget to reward if it helps!
    thanks
    Message was edited by: Murali

  • Regarding Date Function

    Hi All,
    Hi i want to implement the functionality as below, if i gave the Date as Input then i have to get the Respective Timezones is it possible, if yes then can u plz produce a sample snippet of it.
    With Regards,
    Justin

    java.text.SimpleDateFormat to parse and format a date in any time zone.

  • Regarding date function module

    Hi abapers,
    We have one requirement in selection screen validation.
    From date is Day 1 of the next period(month).
    To date is Day 1 of the next period*(month) + (next) 3 months.
    which function module we can use.
    how we can pass the selection screen of this date.
    Thanks
    Nani.

    Hi
    Why we need the fun module
    Just write the code as
    select-options : s_date for sy-datum no display.
    data: date like sy-datum, fdate like sy-datum, tdate is like sy-daum, mon(2),
           mon1(2), mon2(2), year(4).
    date =  sy-datum.
    year = date+0(4).
    mon = date+4(2).
    mon1 = mon + 1.
    mon2 = mon + 3.
    concatenate year mon1 '01' into fdate.
    concatenate year mon2 '01' to tdate.
    use the fdate and tdate and write the code
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Query regarding sys_context function

    Hello
    I have created report with custom folder and parameters are passed using sys_context function. I have few queries regarding this.
    1) How to see actual sql query executed by report. I can see from discover administorator - sql inspector. But it is not showing which is value passed for sys_context parameter. If want to see query with full parameter then what to do? I have also tried to look it from toad - session browser, there also it is not showing parameter value.
    2) If anything special needed to manage sys_context variable. i.e i have executed report with parameter 1 = A and now next time executed with parameter 1 =b. Will it takes proper value, i mean sys_context parameter will be refreshed itself, or need to do somehting..
    Please help me out.
    Thanks in advance

    Hi,
    How to see actual sql query executed by reportSYS_CONTEXT returns values from a namespace. Normally you create a local namespace and values in this namespace can only be retrieved by the session. So there is no way to see the values for a Discoverer session from Toad. Normally, one would create a Discoverer report that returns all the values in your namespace that you can use for debugging.
    If anything special needed to manage sys_context variableNo, once you have set the context in the namespace using DBMS_SESSION.set_context then it is there for the rest of the session.
    Rod West

  • Query regarding date arithmatic

    hi
    i want to write the procedure which will give me the difference of two dates in hours.
    there are two columns start_dt and end_dt and i want to calculate the difference between them in hours.
    morever i want to add functionality like if the start or end date falls on weekend(saturday & sunday) i want to subtract that whole period(which obviously will be in hours) from the total hours elapsed between two dates.
    could anyone please help me in this?
    regards,
    PD

    Diff in hours:
    (end_dt-start_dt)*24Please use the PL/SQL for SQL question.
    Nicolas.

  • Query regarding date format in BIP

    Hi
    1. Is there a way to find the date format which is set in the parameter.
    for eg.- Suppose there is a parameter Startdate mentioned in the format dd-mm-yyyy. If user chooses Startdate: dd-mm-yyyy, can we find the format, so that we can always convert it to one standard dd-mon-yyyy format?
    2. Is there a way to always convert the date to standard dd-mon-yyyy format in BI . Is there an option in BI to do this?
    Thanks
    Amit

    Amit,
    Get your date in this format in XML.
    YYYY-MM-DDThh:mm:ss+HH:MM
    Then there are lot of functions, you can apply on this to get the formatted date you wanted.

  • Query regarding data extraction

    Hello All,
    I am new to ABAP development. I have been assigned to work on a report, where I have to fetch data for a SC, which will be extracted into an flat file.
    Now my requirement is as below:
    Each shopping cart will have a number of different records. The records are of the following types
    Header – Marked with record type = “HEAD”
    Line item – Marked with record type = ”ITEM”
    Accounting line – Marked with record type = ”ACC”
    Approval record – Marked with record type = ”APP”
    Now in this manner I have to fetch the data in an single flat file. Now I am really confused how I am going to do it. I have the tables for header, item, accounting line, approval records. Now my question is am I have to 1st fetch data for header then line then accounts and approval then join this into my final internal table?? Is this the correct approach?
    I am a beginner and your help will be highly appreciated.  
    I have attached a flat file for your reference.
    Regards,
    Sarnava

    So long as you have some unique identifier between each of these tables this shouldn't be a problem. I of course can't see what data you have in the tables but lets say for example you have an account number, then you can create your flat file something like this:
    head,account123,headfield1,headfield2... etc
    item,account123,itemfld1,itemdfld2,....etc
    item,account123,itemfld1,itemdfld2,....etc
    then the same logic of course for the other two lines i.e. the first part of the line is a field which contains "head" or "item" or "acc" or "app", then the unique identifier and then the rest of the records. And you can make it comma seperated or whatever you want. The user picking this up can then also sort it.

  • Query regarding data sending through VISA

    Hi,
    I have to create a program through which I send a Query from one port (1st port ) to another port (2nd port)in form of Hexadecimal array using VISA Read/Write function and when it is recieved it gives out a respone in form of another hexadecimal array to the first port.
    I have no idea how to do it.Please Help.
    Thanks.

    Duplicate post
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Query Regarding Data transfer ( Pls Respond Quickly)

    Hi,
    I need to download the data to XML file. I have hard coded the file path in the Report Program. This Report should be shceduled for every night.
    But the problem is that since I have hard coded the path, whenever the program is deployed to production system there will be a problem regarding the file path.
    Can any body throw some light on how to avoid hard coding of the filepath ?
    Reward points are assured.
    Best  Regards
    Bhagat.

    Hey Kishan,
    In that Program the file path was hard coded. Can you let me know the alternate way so that I can avoid hard coding.
    The thing is that that report should be scheduled  for every night.
    Best Regards
    Bhagat.

  • Query regarding data loading from xls

    Hi
    I want to read data ( integers , only one column) from xls file. I donot want to load it in a table otherwise I could have tried using loader. But what I need to do is I have lakhs of rows in excel sheet and I need to pick them up in a query . I cannot create a table also as working on production . I s there any way I can pick it directly from the excel sheet as I it large volume and I cannot keep them in ( in.. clause) also .

    I want to read data ( integers , only one column)
    from xls file. I donot want to load it in a table
    otherwise I could have tried using loader. But what
    I need to do is I have lakhs of rows in excel sheet
    and I need to pick them up in a query . I cannot
    create a table also as working on production . I s
    there any way I can pick it directly from the excel
    sheet as I it large volume and I cannot keep them
    in ( in.. clause) also .Lakhs of rows!!!! You do realise that an excel spreadsheet is limited to 65536 rows? I'm right in thinking 1lakh = 100000 aren't I?

  • Query regarding date

    hello to all
    guy's in a form i m having an item i.e refdate now i want to work it like this
    that i can insert date data in ddmmyy form and when i press tab or move to other item my date should come in the
    dd/mm/yyyy format in refdate item
    plz help me out ....
    Edited by: Navdeep Kaur on Jul 27, 2009 10:08 PM

    Navdeep,
    I wrote DD/MM/RRRR not DD/MM/YYYY. If you use RRRR instead of YYYY, then the user can enter 2 digit year, and it will automatically convert to 4 digit year.
    Regards,
    Manu.
    If this answer is helpful or correct, please mark it. Thanks.

Maybe you are looking for