Add number of years ?

Hi,
Suppose I am having date '28-feb-2007'. I want to add 1.9 years into this ? How can I do this ?
thanks & regards
pjp

Why not use Julian Dates?
Assuming 1.9 years is 693.5 days, round that to 693...
  1  SELECT TO_CHAR(TO_DATE('20040229', 'YYYYMMDD'), 'J') "2/29/04",
  2         TO_CHAR(TO_DATE('20040228', 'YYYYMMDD'), 'J') "2/28/04",
  3         TO_CHAR(TO_DATE('20070228', 'YYYYMMDD'), 'J') "2/27/07",
  4         TO_NUMBER(TO_CHAR(TO_DATE('20040229', 'YYYYMMDD'), 'J'))
  5         - TO_NUMBER(TO_CHAR(TO_DATE('20040228', 'YYYYMMDD'), 'J')) "2/29 - 2/28",
  6         TO_NUMBER(TO_CHAR(TO_DATE('20050228', 'YYYYMMDD'), 'J'))
  7          - TO_NUMBER(TO_CHAR(TO_DATE('20040228', 'YYYYMMDD'), 'J')) "2/28/05 - 2/28/04",
  8         TO_NUMBER(TO_CHAR(TRUNC(SYSDATE), 'J')) "Julian",
  9         TO_NUMBER(TO_CHAR(TRUNC(SYSDATE), 'J')) + TO_DATE('365', 'J') "Today+1.0",
10         TO_NUMBER(TO_CHAR(TRUNC(SYSDATE), 'J')) + TO_DATE('693', 'J') "Today+1.9",
11         TO_NUMBER(TO_CHAR(TRUNC(SYSDATE), 'J')) + TO_DATE('730', 'J') "Today+2.0"
12* FROM DUAL
10:40:17 SFF@MIPSLPPE/10.2.0.3
SQL> /
2/29/04 2/28/04 2/27/07 2/29 - 2/28 2/28/05 - 2/28/04     Julian Today+1.0 Today+1.9 Today+2.0
2453065 2453064 2454160           1               366    2454165 04-MAR-08 26-JAN-09 04-MAR-09
1 row selected.Sam

Similar Messages

  • How to add number of years to date

    Hello,
    How can I add a number of years (age) to a date (not the current date, the birth date, chosen from a DatePicker).
    Thank you,
    Ioana.

    Wow, that was fast :)
    Sorry for the double post, wasn't sure the first one was published.
    Thanks a lot, I've managed to add the the age correctly.
    Ioana.

  • I have Photoshop CS3 which I have used successfully for a number of years.  I now shoot pics with a Nikon DSLR D7100. When I try to open NEF files the following flag appears: "Could not complete your request because PS does not recognize this file.  What

    I have Photoshop CS3 which I have used successfully for a number of years.  I now shoot pics with a Nikon DSLR D7100. When I try to open NEF files the following flag appears: "Could not complete your request because PS does not recognize this file".  What do I need to do to open my NEF files??  Thanks.

    Thanks for the quick reply, CP
    FYI, the file is a photographic panorama based on several .CR2 photos taken in July, 2012 and processed in CS5's camera RAW/Photoshop.  Beyond the metadata, here are no fonts or text in the file.
    1.  I changed Maximize ...File Capability from "Never" to "Always" and the flattened file saved and loaded OK, though I can't figure why given Adobe's description of this option. "If you work with PSD and PSB files in older versions of Photoshop or applications that don’t support layers, you can add a flattened version of the image to the saved file...".  The file saved in this manner is ~8% larger and is not my preference as a routine since I've TB's of photo files.  By the way, out of thousands of .psd/.psb files, the one being discussed is the first to give me the error.
    2.  I've tried saving/reloading the file on another computer with Win XP Sp3/CS5...again with Maximize Capability OFF.  Same problem.  Turn ON Maximize Capability and it works.  As with the Win 8 machine, Bridge could neither create a thumbnail or read Metadata.
    3.  I've purged the Bridge Cache, made sure there were no old PS page files, reset PS preferences, and disabled my 2 plugins with no change in the problem.  Windows and Adobe progs are all updated.  Saving to a different HDD has no effect.
    The problem occurs on 2 computers (Win XP/Win 8), two versioins of Photoshop (CS5/CS6), and "Maximize" On/Off togles the problem.  My guess it is a bug in PSD processing routines.
    If I can't find a fix, will keep with Maximize ON and deal with the larger files that result...the cost of insurance, I suppose.
    Thanks again

  • How to find out number of  years worked using sql

    Hello,
    How to find from a table which has hiredate and should return number of years worked with range like 0-5, 5-10,10-15 etc.
    Any help is highly appreciated.
    Thanks

    I think this query can solve your issue
    SELECT CASE yeared,COUNT(CASE) FROM
    SELECT
    CASE
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=5 THEN '0-5'
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 5 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=10 THEN '5-10'
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 10 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=15 THEN '10-15'
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 15 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=20 THEN '15-20'
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 20 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=25 THEN '20-25'
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 25 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=30 THEN '25-30'
    ELSE '>=30'
    END CASE
    FROM scott.emp )
    GROUP BY CASE
    Regards.

  • Need to add number of days to users end date.

    Hi,
    I have a code where we are adding number of days(30) to current date and then updating user's end date in IDM DB.
    Now we have a requirement where we need to add number of days(30) to existing end date of user instead of adding to current date.
    *public String incrementDate(int daysToAdd)
         // Start date
         log.info("NotifyLastDayOfService::incrementDate(): Enter");
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
         Calendar c = Calendar.getInstance();
         c.add(Calendar.DATE, daysToAdd); // number of days to add
         String newDate = sdf.format(c.getTime());
         log.info("NotifyLastDayOfService::incrementDate(): Exit");
         return newDate;
    Have any body implemented this scenario?
    Please suggest.
    Thanks,
    Kalpana.

    Hi Nayan,
    Here is the code:
    System.out.println("----inside increment date method-----");     
              HashMap<String, String> hm = new HashMap<String, String>();
              HashMap<String,Date> modifyMap=new HashMap<String,Date>();
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
              tcResultSet usrList = null;
         String enddate = null;
         hm.put("Users.Key",usrKey );
         try {
         usrList = this.usrIntf.findUsers(hm);
         usrList.goToRow(0);
         Date endDate =usrList.getDate("Users.End Date");
         System.out.println("-----users end date-----"+endDate);
         String userEndDate=sdf.format(endDate);
         System.out.println("-----String value of users end date-----"+userEndDate);
         Calendar cal=null;
         System.out.println("-----Calender date-----"+cal);
         cal.setTime(endDate);
         System.out.println("-----end date-----"+endDate);
    cal.add(Calendar.DATE, Integer.parseInt(daysToAdd)); // number of days to add
    Date newEnddate = cal.getTime();
    System.out.println("-----new end date-----"+newEnddate);
    //usrList.setEndDate(Edate);
    modifyMap.put(userEndDate,newEnddate);
    usrIntf.updateUser(usrList, modifyMap);
    System.out.println("updated user's end date in OIM DB");
    //System.out.println("-----updated user's end date in OIM DB-----");
    logger.info("NotifyLastDayOfService::incrementDate(): Exit");
         System.out.println("-----new date-----");
         } catch (tcAPIException e) {
         logger.error("Error in finding end date for user" + e);
         } catch (tcColumnNotFoundException e) {
         logger.error("Error in finding end date for user" + e);
    In th log file, I can see that the code is not executing this line:
    cal.setTime(endDate);
    end date is of type Date and stores users end date from DB. Please help in resolving this issue.
    Thakns,
    Kalpana.

  • How can i do if i want to add number to the filenames of my pic in my macpro

    how can i do if i want to add number to the filenames of my pics in my macpro? if someone can help

    You could look into utilities like A Better Finder Rename or similar apps on the page I linked to.

  • Add number of business days to date field

    Hello, I noticed that there is not much discussion in the forum surrounding u201Cbusiness daysu201D so I hope this post/discussion/solution contributes to the content of this forum.
    I am using the following 3 formulas to try to Add number of business days (based upon a table field) to a specified date:
    1. Variable name = SetVar
    //Set Variable for Add Business Days:
    DateVar Array Holidays;
    DateVar Target:= CDate({TMS_MOVEMENT_EVT.EVT_DATE}); // Put your field name in here
    NumberVar Add:=  {DTCI_DOD_TRANS.TRANS}; // put the number of days here to add (a positive number)
    NumberVar Added := (0);
    2. Variable name = AddBizDays
    //Adding Business Days:
    EvaluateAfter({@SetVar});
    WHILE Added < Add
    Do (target := target +1;
        if dayofweek (target) in 2 to 6 and not (target in holidays)
            then Added:=Added+1
            else Added:=Added);
    Target
    3. Variable name = HOLIDAYS
    //Holiday Array Formula for the report Header:
    BeforeReadingRecords;
    DateVar Array Holidays := [
    Date (2003,12,25),   // you can put in as many lines for holidays as you want. 
    Date (2003,12,31)
    0
    I am successfully getting my data needed to make the necessary calculations and variable assignmentsu2026 I believe that my ISSUE is that I am not sure where to place these formulas into my report so they assign the variables and execute properly when previewing my report. I am curious if that is my issue, and if so, can someone provide me direction on where to put each of these formulas in my report.
    Currently, when I try to preview the report, I get the following Crystal Reports Error:  -u201CA number, currency amount, Boolean, date, time, date-time, or string is expected here.u201D
    Then Crystal automatically opens the AddBizDays formula and highlights the word added, see below RE: u201CWHILE Addedu201D
    For reference, my report has 3 groups, and I am displaying all of my output information (and locating my formulas) in the group footer #3 report section. I have moved them around to other report sections/groups/placements, but to no success.
    Thanks so much.
    Best, Matt

    I worked this out... FYI - for the benefit of all forum users:
    ADDING BUSINESS DAYS TO A CERTAIN DATE (excluding weekends and holidays)
    1. Variable name = AddBizDays
    //Adding Business Days:
    WhileReadingRecords;
    DateVar Array Holidays;
    DateVar Target:= CDate(); // Put your field name in here
    NumberVar Add:=  ; // put the number of days here to add (a positive number)
    NumberVar Added := (0);
    WHILE Added < Add
    Do (target := target +1;
        if dayofweek (target) in 2 to 6 and not (target in holidays)
            then Added:=Added+1
            else Added:=Added);
    Target
    2. Variable name = HOLIDAYS
    //Holiday Array Formula for the report Header:
    BeforeReadingRecords;
    DateVar Array Holidays := [
    Date (2003,12,25), // you can put in as many lines for holidays as you want.
    Date (2003,12,31)
    0
    ...too bad i don't get forum points for sharing this solution.
    Special thanks to KenHamady.com -- for sharing this solution.
    Sincerely,
    Matt

  • Is it possible to add number of days to date?

    I am working on a form where I need to add number of days to a date and come up with a date.
    Header 1
    Header 2
    example date:  March 1, 2013
    + 30
    = march 31 2013                
    1. is this possible? Header1/cell 1 is a date field. Header 2/cell 1 is a dropdown field (30, 60, 90,120, custom),.
    Header2 cell2 not sure what field to use date or text?
    thank you

    Never mind I figured it out. Thanks

  • How to get the number of years, months with two sysdate()

    Hi All,
    Sorry for posted another question regarding the conversion.
    I have the hiring day and current day in date format like : '2005-10-01' and '2006-09-14'
    How to get the differences between current date is ('2006-09-01') and
    hiring date is ('2004-10-01' )
    in the format number of years and number of month without using the Mod
    function . For this example the result is : 2 years 1 month
    Thanks
    JP

    How to get the differences between current date is ('2006-09-01') and
    hiring date is ('2004-10-01' )
    in the format number of years and number of month without using the Mod
    function . For this example the result is : 2 years 1 monthshould not it be 1 year 11 months???
    SQL> select (date '2006-09-01' - date '2004-10-01') year to month diff from dual;
    DIFF
    +01-11

  • Skype Number to yearly basis

    I'd like to change monthly payment of Skype Number to yearly basis. How can I do?
    Solved!
    Go to Solution.

    Hi, Edokko, and welcome to the Community,
    As strange as it sounds, this is how to change the term of your Skype Number subscription:
    Cancel, yes; cancel, your current month-to-month Skype Number subscription.  This will prevent the month-to-month subscription from renewing.  You have use of the Skype Number until the last day of the subscription.
    Sign on to your account dashboard the next day or even the day of your current subscription's expiration, where you should be greeted with a triangle icon alerting you to reactivate your Skype Number.  Click on the link beside it, where you will be able to reinstate your subscription for a longer term.
    (Your Skype Number will be held on your account for 90 days after the month-to-month subscription ends.)
    Regards,
    Elaine
    Was your question answered? Please click on the Accept as a Solution link so everyone can quickly find what works! Like a post or want to say, "Thank You" - ?? Click on the Kudos button!
    Trustworthy information: Brian Krebs: 3 Basic Rules for Online Safety and Consumer Reports: Guide to Internet Security Online Safety Tip: Change your passwords often!

  • Date from Day number and year

    Dear experts,
    i have day number and year ,i wanted to identify the date
    ex: day number=203 year=2009
    date:22/07/2009
    please advice the best possible way to acheive this.
    thanks

    Florian:
    Given that the OP said his fields were VARCHAR2, and his sample data showed leading zeroes, your original solution will work as posted. If the data had been numeric, another solution would be to just reverse the order of the components.
    SQL> WITH t AS (
      2     SELECT 2009 yr, 203 day_no FROM dual union all
      3     SELECT 2006, 201 FROM dual union all
      4     SELECT 1999,  99 FROM dual union all
      5     SELECT 2000, 001 FROM dual union all
      6     SELECT 1945, 100 FROM dual union all
      7     SELECT 1921, 101 FROM dual)
      8  SELECT TO_DATE(yr||day_no, 'yyyyddd') dt FROM t;
    DT
    22-JUL-2009
    20-JUL-2006
    09-APR-1999
    01-JAN-2000
    10-APR-1945
    11-APR-1921It is the way that format masks are applied that causes his. With your mask and numeric iinput, it is taking the first 3 digits as the day number, in your example 902, then the remainder of them as the year, in your example 9. Obviously, the number of days in a year is never more than 366.
    By reversing the mask, the first 4 digits are taken as the year, and the remainder are taken as the day number.
    John

  • I have used Firefox for the last number of years but now it crashes upon opening.

    I have used Firefox for the last number of years but now it crashes upon opening. I have unistalled and installed (version 6) but still it crashes. It does not start in safe mode either. I have read the various help support but I seem to be going around in circles. I am not a computer geek so please bear with me. Thank you.

    Create a new profile exclusively for the 4.0 beta version and create a desktop shortcut with -P "profile" appended to the target to launch that profile.
    * http://kb.mozillazine.org/Testing_pre-release_versions
    * http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
    * http://kb.mozillazine.org/Shortcut_to_a_specific_profile
    * http://kb.mozillazine.org/Using_multiple_profiles_-_Firefox

  • Matrix : how add number in column (V_-1)

    hi,
    i have created a matrix using screen painter but how can i add number under the # column (V_-1) ? do it in screen painter or coding ? As i notice, by the default, the number is increment as the record increase .
    e.g in the Matrix (it is inside a new screen)
    V_-1      V_0            V_1
           Doc Num       Value
    1                 1              1
    2                2                88
    3               3                  409
    Thanks

    Hi
    You have to write code for this , each time when you add or delete row you have to assign the row no through code.
    Dim oMatrix As SAPbouiCOM.Matrix = form.Items.Item("matrix").Specific
                        Dim oEdit As SAPbouiCOM.EditText
                        For iRowCount As Integer = 1 To oMatrix.RowCount
                            oEdit = oMatrix.GetCellSpecific("V_-1", iRowCount)
                            Try
                                oEdit.Value = iRowCount.ToString.Trim
                            Catch ex As Exception
                            End Try
                           ... Or
                            form.DataSources.UserDataSources.Item("RowNo").ValueEx = iRowCount.ToString
                        Next
          form.DataSources.UserDataSources.Item("RowNo").ValueEx = iRowCount.ToString for this to work you have to add a user data source ("RowNo") to your form and bind it with your column
    Hope this helps you
    Regards
    Arun

  • Number Ranges Year Wise

    Hello All,
    This is with the reference to the Thread
    [Number range;
    My client want to maintain the number ranges year wise for Billing, Orders etc., We have suggested not to go with Year wise  best practise
    Is there any OSS notes which tells that number ranges can not be maintained fiscal year wise?
    Regards,
    Narasimha Kumar

    As said in above replies,
               You can achieve the same by using USEREXIT_Number_range in include;RV60AFZZ.
    where create new Ztable = ZNR_Billing:
    Year / Sales Organization / Distribution chanel(Optional) / NR interval.
    eg: 2010 / Z100 / Z1 = ZZ
    where Z100 -= Sales Org & Z1 = Dist Channel &
    ZZ = Number range Interval (maintain number ranges in SNRO for ZZ- Make sure interval should not be overlap with other number ranges, but i dont think its possible.
    eg:
    Z1:2009--> 1000 - 9000
    at the same time you cant create another number range in SNRO as Z2:1000-9000 ( numbers will overlap)
    But i f you dont maintain same numbers in different years, then you can use the above Userexit, but still doesnt have any sense to use Userexit, when you dont maintain same numbers.

  • Convert two dates difference to number of years, months and days

    Post Author: gigimonu
    CA Forum: Formula
    I wanted to write a formula (if there is a function I can use) that can convert a date difference to total number of years, months and days example
    adate = 10/22/2006
    ?xdate = current date - adate (answer should be 1 years, 0 months and 0 days)
    Please help
    Thanks

    Post Author: V361
    CA Forum: Formula
    &#91;Years, Months, Days&#93;
    DATEVAR FROMDATE := DATE(2000,01,01); // FROM DATE
    DATEVAR TODATE := CURRENTDATE; // TO DATE
    NUMBERVAR YEARS;
    NUMBERVAR MONTHS;
    NUMBERVAR DAYS;
    STRINGVAR DIFF;
    DATEVAR TEMP;
    IF TODATE < FROMDATE THEN
    (TEMP := TODATE;
    TODATE := FROMDATE;
    FROMDATE := TEMP);
    YEARS := DATEDIFF('YYYY',FROMDATE,TODATE);
    IF YEARS > 2 THEN
    (YEARS := YEARS - 2;
    TEMP := DATE(DATEADD("M",YEARS * 12,FROMDATE));)
    ELSE
    (YEARS := 0;
    TEMP := FROMDATE);
    WHILE TRUE DO
    (TEMP := DATE(DATEADD('M',1,TEMP));
    IF TEMP > TODATE THEN
    EXIT WHILE;
    MONTHS := MONTHS + 1);
    DAYS := DATEDIFF('D',DATE(DATEADD('M',-1,TEMP)),TODATE);
    IF MONTHS > 12 THEN
    (YEARS := YEARS + INT(MONTHS/12);
    MONTHS := MONTHS MOD 12);
    DIFF := IIF(YEARS>0 ,TRIM(TOTEXT(YEARS,0)) & " YEARS " ,"0 YEARS ") &
    IIF(MONTHS>0,TRIM(TOTEXT(MONTHS,0))& " MONTHS ","0 MONTHS ")&
    IIF(DAYS>0 ,TRIM(TOTEXT(DAYS,0)) & " DAYS" ,"0 DAYS");

Maybe you are looking for