1 & 2 Year Calendar Date Calculations

Hi All,
I am a total newbie to designing forms so please bear with me.
I am currently working with a lease form and i need to do the following:
I want to be a to fill in a date field with a Lease Start date: ex.. "09/01/2010"
and have a script or calculation output the corresponding 1 and 2 year Lease End Dates to separate date fields.
which in this case would be 1 year "08/31/2011" 2 year "08/31/2012".
I want it to verify that the dates are correct and account for leap years.
I would prefer if this could be done in Formcalc, as I have no experience whatsoever in using Javascript.
Thank you in advance for any help you guys can provide.

I just created a sample foe someone else on this same topic. In this instance using Javascript is easier than FormCalc so that is what I used. We can take the date field and separate it into its components of day, month and year. Once we have the year we can add 1 or 2 to it and then simply put the date back together again to make a date. This way we do not have to worry about leap years ar adding 365.25 days. Have a look at the code ..it is pretty straight forward. If you have questions do not hesitate to ask. The code is on the click event of the button.
Paul

Similar Messages

  • DAX - Year to Date Calculation

    Hi All,
    We have a requirement of calculating the Year to Date Calculation in DAX for No. of Sales. Below is the table that we are using:
    Year
    Quarter
    Date
    No. of Sales
     If we browse the tabular model with Year/Quarter then formula should calculate the value at quarter levels.
    Formula Definition for Q1 = (Total of “No. of Sales” in current Year upto Q1  / Total of “No. of Sales” in previous Year upto Q1) -1
    Formula Definition for Q2 = (Total of “No. of Sales” in current Year upto Q2  / Total of “No. of Sales” in
    previous Year upto Q2) -1
    Formula Definition for Q3 = (Total of “No. of Sales” in current Year upto Q3  / Total of “No. of Sales” in
    previous Year upto Q3) -1
    Formula Definition for Q4 = (Total of “No. of Sales” in current Year upto Q4  / Total of “No. of Sales” in
    previous Year upto Q4) -1
    Can anybody help us in building this formula in DAX which should be able to browse with any columns of the table.
    Thanks,
    Vishal Jharwade

    Hi Vishal,
    According to your description, we are still not clear about your requirement. Do you want to calculate the "current YTD/previous YTD -1"? Or you want to calculate the Total Year to Quarter for each quarter?
    If you want to calculate the first one, please use the formula below:
    =[Sales](DATESYTD(DimDate[Datekey])) - [Sales](DATEADD(DATESYTD(DimDate[Datekey]),-1,YEAR))
    If you want to calculate the second one, you can use TotalYTD() function to calculate the Year to Quarter value:
    =TOTALYTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey], ALL(‘DateTime’), “3/31”)
    However, since we have to specify a literal string with a date that defines the year-end date, it can't make it dynamically to show the Year to Quarter for the current quarter. So you still can't use only one formula to deal with all quarters.
    Reference:
    First steps in DAX: Year-To-Date
    Time Intelligence Functions in DAX
    Best Regards,
    Simon Hou
    TechNet Community Support

  • Are Cube organized materialized view with Year to Date calculated measure eligible for Query Rewrite

    Hi,
    Will appreciate if someone can help me with a question regarding Cube organized MV (OLAP).
    Does cube organized materialized view with calculated measures based on time series  Year to date, inception to date  eg.
    SUM(FCT_POSITION.BASE_REALIZED_PNL) OVER (HIERARCHY DIM_CALENDAR.CALENDAR BETWEEN UNBOUNDED PRECEDING AND CURRENT MEMBER WITHIN ANCESTOR AT DIMENSION LEVEL DIM_CALENDAR."YEAR")
    are eligible for query rewrites or these are considered advanced for query rewrite purposes.
    I was hoping to find an example with YTD window function on physical fact dim tables  with optimizer rewriting it to Cube Org. MV but not much success.
    Thanks in advance

    I dont think this is possible.
    (My own reasoning)
    Part of the reason query rewrite works for base measures only (not calc measures in olap like ytd would be) is due to the fact that the data is staged in olap but its lineage is understandable via the olap cube mappings. That dependency/source identification is lost when we build calculated measures in olap and i think its almost impossible for optimizer to understand the finer points relating to an olap calculation defined via olap calculation (olap dml or olap expression) and also match it with the equivalent calculation using relational sql expression. The difficulty may be because both the olap ytd as well as relational ytd defined via sum() over (partition by ... order by ...) have many non-standard variations of the same calculation/definition. E.g: You can choose to use or choose not to use the option relating to IGNORE NULLs within the sql analytic function. OLAP defn may use NASKIP or NASKIP2.
    I tried to search for query rewrite solutions for Inventory stock based calculations (aggregation along time=last value along time) and see if olap cube with cube aggregation option set to "Last non-na hierarchical value" works as an alternative to relational calculation. My experience has been that its not possible. You can do it relationally or you can do it via olap but your application needs to be aware of each and make the appropriate backend sql/call. In such cases, you cannot make olap (aw/cubes/dimensions) appear magically behind the scenes to fulfill the query execution while appearing to work relationally.
    HTH
    Shankar

  • Month to Date and Year to date calculation

    Hello Experts,
    It would be great If you could provide the formula to implement in BO universe or in the Reporting level for the below requirement.
    MTD, LastMonth, Year to Date, Last to LastMonth and examples are below.
    Last Week:
    Eg: Monday through Sunday
    Description: Based on Todayu2019s date, select the Monday of the previous week for the start date and Sunday will be the end date.
    Example:
    If Today is May 22, 2009
    The result would be, Monday = May 11, 2009, Sunday = May 17, 2009
    MTD:
    If Today is May 22, 2009
    I need a result MTD = May 1, 2009 u2013 May 21, 2009
    LastMonth:
    If Today is May 22, 2009
    I need a result LastMaont = April 1, 2009 u2013 April 30, 2009
    Last to LastMonth:
    If Today is May 22, 2009
    I need a result LastMaont = March 1, 2009 u2013 March 31, 2009
    Thank you.

    Nisniki,
    Here are the methods using WebI:
    MTD: 
    Create a local variable "MTD Start"
    =RelativeDate(LastDayOfMonth(RelativeDate(CurrentDate();-30));1)
    Create a local variable "MTD End"
    =currentdate()
    LastMonth
    =LastDayOfMonth(RelativeDate(CurrentDate();-30))
    Year to Date
    create a local variable "YTD Begin"
    =ToDate("01/01/"+FormatNumber(Year(CurrentDate());"####");"mm/dd/yyyy")
    (reuse "MTD End" or build a "YTD End" variable same as "MTD End")
    Last to LastMonth
    (similiar to MTD, but using "60" versus "30" to move back two months versus moving back 1 month.
    To perform this stuff in the universe requires an understanding of the SQL syntax for the paricular vendor your are working with.  ANSI SQL agrees to represent and compute dates uniformly, however, the functions to make it happen varies by the vendor.
    Thanks,
    John

  • Regarding year to date Calculations

    Hello,
            I Have a requirement to calculate the Year to date. When i input the value 009/2008 the exit should calculate the value from 001/2008 - 009/2008. the values should cumulate.
    For eg: For the period: 002/2008 value is 10
                                     003/2008 value is 20.
        cumulative value should be 30.
    Thanx in advance

    Hi,
    there are content varables that you can use in a query for this purpose. They are deliverd for the InfoObjects 0CALMONTH (0CYTLM: 'Cumulated to last month' or 0CYTCM 'Cumulated to current month' for example) and 0FISCPER. They select the complete range from periode 01 to your actuel month and therfore give you the cumulated value.
    Hope that helps
    Regards
    Christoph Vortkamp

  • Year to date calculations

    Hi All,
    I am using Planning V11
    I wanted to display YTD data on webforms. Now the data is loaded at the month level and there is a requirement to see the values for YTD aswell.
    I wanted to know the best practices around calculating YTD data in planning.
    There is a specific requirement to display periodic and YTD data on data forms.
    Your inputs and suggestions would be really helpful.
    Cheers,
    XXX

    It's possible, but mildly tricky.
    The reason is this . . . you would ideally like to calculate this variance on the database (in Planning/Essbase) and not on the form, which would require custom JavaScript. Unfortunately, with Planning, there are significant restrictions on what you can do with years. They have to start with FY and be followed by two numbers, and so on. What you would really like to do is create a "variance" year with a member formula that says, "@VAR(&ThisYear, &LastYear). But you can't do that in planning.
    So what you COULD so is this . . . create a variance Scenario that calculates the year-over-year variance for a given Scenario. The formula would look something like this @VAR(&ThisYear->"Budget", &LastYear->"Budget") The members with the "&" are substitution variables, if you weren't aware. I would make this variance scenario dynamic. You would need a separate member for each scenario where you wanted a variance, but it would work.
    Then on your forms, you would have the following dimensions in your columns: Scenario, Year, Period.
    Column 1 would be: "Budget", &ThisYear, YTD(&CurrentPeriod)
    Column 2 would be: "Budget", &LastYear, YTD(&CurrentPeriod)
    Column 3 would be: "Budget This Year vs Last Year", &ThisYear, YTD(&CurrentPeriod)
    This is just one idea. There are other ways to achieve this.
    Hope this helps,
    - Jake

  • Year to Date Calculation in Discover Report

    Hi,
    I've got a problem with calculated items in discoverer which I just can't seem to find an easy answer for.
    I have a matrix report with 6 columns as and the time period as page item as follows:
    Month: June 2002
    Sales Budget Variance Sales YTD Budget YTD Variance
    However, I don't know how to calculate the Sales YTD and Budget YTD as these values are variable dependent on the month selected.
    Any answers, (especially quick and easy answers) are greatly appreciated.
    Thanks in advance!!!

    You could setup a table that would include Date.. and values for the six data elements. This table could be populated nightly. This moves much of the complexity of your request out of discoverer and into the database.
    If you are wanting to continue to develop in discoverer only then you will need to create Functions and access them from discoverer.
    Best of Luck,
    Christopher
    www.billboard.net

  • Calendar Date Calculation

    What's wrong with my following statement?
    I always get compilation,
    class XX
    Calendar calendar = Calendar.getInstance();
    Calendar cal1 = calendar.add(calendar.MONTH,1); //incompatible types error
    Date expiry = cal1.getTime();
    but I got the requirements asking for <identifier> in the 2nd version
    class XX...
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.add(calendar.MONTH, +1); //identifier need
    Date expiry = calendar.getTime();
    but it works when it is declared under
    class {
    public static void main(String[] args)
    {  GregorianCalendar calendar = new GregorianCalendar();
    calendar.add(calendar.MONTH, +1); //identifier need
    Date expiry = calendar.getTime();
    However, I am not going to declare it under main.
    Pls help!

    In the first two cases, you haven't put the statements in a method, where they belong. In the last, you did, so it worked. You can have methods other than main(), of course.
    You should post real code and real error messages when you ask a question...

  • Year to date calculation

    Hi experts,
    I need to create a request where I calculate year_todate costs for the previous year (one year ago)
    Let's say I have the following figures for 2000:
    year________Month_________Day______Acutal Coasts
    2000________Jan___________1____________10
    2000________Jan___________2____________20
    2000________Jan___________3____________30
    I used the AGO function to retrieve the previous year costs so I end up with the following request:
    year________Month_________Day______Acutal Coasts_____Previous year costs
    2001________Jan___________1____________5_________10
    2001________Jan___________2____________6_________20
    2001________Jan___________3____________7_________30
    And to calculate the year_todate costs and I tried OBIEE to_date fucntion :TO_DATE(Previous year costs) , the results was:
    year________Month_________Day______Acutal Coasts_____Previous year costs
    2001________Jan___________1____________5_________10
    2001________Jan___________2____________6_________30(10+20)
    2001________Jan___________3____________7_________60(10+20+30)
    When I look at the results at Month level
    year________Month______Acutal Coasts_____Previous year costs
    2001________Jan____________5_________100 (10+30+60)
    It's summing up all the coasts at day level and I only need the last value of a month, or a year if I want to display the results at year level.
    I also tried to use the RSUM function, but because it's only a display function when I filter on a day (for example day 2 JAN) I only got the results without any running sum:
    2001________Jan___________2____________6_________20 (because I exculed the other days with the filter)
    Any ideas how I achieve this:
    year________Month______Acutal Coasts_____Previous year costs
    2001________Jan____________5___________60 when I look at the month level
    and
    2001________Jan___________2____________6_________30 when I look at the day level.
    Regards

    Thanks venkat for the answer.
    It's only solving the problem at month level
    year________Month______Acutal Coasts_____Previous year costs
    2001________Jan____________5___________60 when I look at the month level
    but at day level it's just repeating the value at month level for every day
    year________Month_________Day______Acutal Coasts_____Previous year costs
    2001________Jan___________1____________5_________60
    2001________Jan___________2____________6_________60
    2001________Jan___________3____________7_________60
    and I want to have the following if I filter on 1JAN and 3JAN
    year________Month_________Day______Acutal Coasts_____Previous year costs
    *2001________Jan___________2____________6_________30(10+20)*
    Regards

  • Year to Date using SAP variables

    I've run into a sticking point when trying to create a year to date calculation that works without user entry. The infocube is updated by finance each month (for the previous month) after the final adjustments are made. For this reason, when the query pulls YTD information, it should be cumulating from January 20XX to Current Month - 1.
    The first way that I tried was to use overlapping restrictions: Fiscal Year/Period < Current Fiscal Year/Period AND Fiscal Year = Current Fiscal Year. This worked very well until we reached January. Now the overlapping restrictions return no results since all previous months are not in the current fiscal year.
    I've also attempted using the SAP exit variable 0FYTLFP (Cumulated to Last Fiscal year Period) on Fiscal Year/Period. It is not working, and I assume it is because the last fiscal year period is falling into a different fiscal year. Using it today, the value I get is equal to the value for Jan 2007. The variable seems to first look up the first day of the current fiscal year, saves that as one end of the range, then goes to the previous month to get the other end of the range. I tried offsetting this variable by -1 and the value returned was equal to Dec 2006, but not YTD.
    I'm assuming it must be possible to use the standard SAP delivered objects to create a working YTD calculation that does not require manual entry and cumulates correctly through current period - 1. Does anyone have any suggestions?
    Thanks!

    Dear Adam,
    For Year to Date , We have created a Customer Exit , For working , Create a Variable for 0calday and populate that with from and to value ...to value would be Sy-datum and From value is year starting date. Hope it helps..
    Thanks,
    Krish

  • Date Calculations - Adding 1 to the day and adjusting month/year

    Hi all,
    I have a date field in MM/ DD/ YYYY format. If I add 1 to the DD (day) field, and I hit the end
    of the month/year I need to adjust the MM and YYYY accordingly.
    Is there is an existing class/method in the JAVA API that would handle somthing like this??
    If so , I can't find it..... I don't want to re-invent the wheel creating a Date Handling routine just
    for this program.......
    Thanks very much

    This is overkill... (and sorry that this post is over a year later than the original post... hopefully somebody will benefit from it :)
    Calendar.getInstance() by default instanciates a GregorianCalendar
    object. (check the src).
    Therefore:
    Calendar cal = Calendar.getInstance();
    cal.setTime(d); // where d = java.util.Date or java.sql.Timestamp
    cal.add(Calendar.DATE, numberOfDays);
    return cal.getTime();
    public static java.util.Date
    adjustDateBy(java.util.Date d, int numberOfDays) {
    java.util.GregorianCalendar cal = new
    java.util.GregorianCalendar();
         cal.setTime(d);
    cal.add(java.util.GregorianCalendar.DATE,
    numberOfDays);
         return cal.getTime();

  • Fiscal Month/Year Date Calculations

    Hi Gurus,
    I am trying to create a fiscal year and fiscal month offset using filter advanced SQL in answers. The “Offset” should allow to define a period of time + or – from a given starting point in order to report on a period of time. For example the Current Month Offset - When the variable is defined and set-up in the “Time” drop down menu in Answers. You would select Current Month Offset and in the create/edit filter dialog the Current Month Offset column contains a value of 0 for the most recent loaded month of data, a value of -1 for the month prior to that and so on. By selecting the “Operator”, “is between” and “Value” -5 and “Value” 0 you would filter to display the last 6 months.
    I created the offset with calendar year using the Advanced filter and worked fine for if i need to change the year to what ever value
    (((YEAR(CURDATE())-YEAR(Time.Date)) * 12) + (MONTH(CURDATE())-MONTH(Time.Date))) * -1 = -1
    The issue comes when i create for Fiscal year and Fiscal month using filter advanced SQL it throws an error
    (((FISCAL YEAR(CURDATE())-FISCALYEAR(Time.Date)) * 12) + (FISCAL MONTH(CURDATE())-FISCAL MONTH(Time.Date))) * -1 = -1
    for fiscal year it throws an error below
    Error getting drill information: SELECT Time."Fiscal Year" saw_0, Time."Fiscal Year" saw_1 FROM "AAFES Procurement - Purchase Orders" WHERE Time."Fiscal Year" = (((FISCAL YEAR(CURDATE())-FISCALYEAR(Time.Date)) * 12) + (FISCAL MONTH(CURDATE())-FISCAL MONTH(Time.Date))) * -1 = -1
    Error Details
    Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <CURDATE>: Syntax error [nQSError: 26012] . (HY000)
    SQL Issued: {call NQSGetLevelDrillability('SELECT Time."Fiscal Year" saw_0, Time."Fiscal Year" saw_1 FROM "AAFES Procurement - Purchase Orders" WHERE Time."Fiscal Year" = (((FISCAL YEAR(CURDATE())-FISCALYEAR(Time.Date)) * 12) + (FISCAL MONTH(CURDATE())-FISCAL MONTH(Time.Date))) * -1 = -1')}
    Thanks
    Simmz

    Hi,
    Kindly refer the below link it may help you.
    http://obieeelegant.blogspot.com/2011/06/obiee-date-expressions-reference.html
    Thanks
    Deva

  • Function module SD_SCHEDULING: delivery date calculation factory calendar

    Hi,
    When I create or change a sales order, system calculates the delivery time and date (ETDAT) using transit duration and factory calendar. Currently factory calendar says that transportation leaves every Monday, Wednesday and Friday. Unfortunately, function module SD_SCHEDULING calculates the delivery date using factory calendar dates, i.e. <b>NOT</b> using working dates.
    Function module reads the factory calendar from table TVRO (Routes) and field SPFBK (Factory calendar key) in subroutine GET_CUSTOMIZING, and saves factory calendar id in CS_SCHEDDU-TRANSIT_FC. The calculation itself is done later in function module DATE_CONVERT_TO_FACTORYDATE.
    For example, if transit duration is 3 working days, function module calculates the delivery date using Monday (first day), Wednesday (second day) and Friday (third day). Thus, the result is Friday, which is wrong. Result should be of course Wednesday (Monday first day, Tuesday second day and Wednesday third day).
    I'd like to use working days instead of calendar days. I am planning to recalculate the delivery date in some user exit, but before I start coding, I'd like to hear your opinion: <i>Is it possible to use working days instead of calendar days when calculating delivery date?</i> (I believe it must be, since my case is very normal). If it is, I assume that this can be achieved with IMG, but how and where?
    I am using SAP R/3 Enterprise.
    Regards,
    Jarmo Tuominen

    Hi jarmo,
    1. DATE_CHECK_WORKINGDAY
       Probably this FM may be useful to u.
    2.
    CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
            EXPORTING
              date                       = d
              factory_calendar_id        = '01'
              message_type               = 'I'
            EXCEPTIONS
              date_after_range           = 1
              date_before_range          = 2
              date_invalid               = 3
              date_no_workingday         = 4
              factory_calendar_not_found = 5
              message_type_invalid       = 6
              OTHERS                     = 7.
    regards,
    amit m.

  • Fiscal Calendar in Report Variant Dynamic Date Calculation

    We are switching from the standard calendar to a 4/4/5 calendar for our fiscal calendar. We have a number of batch reports that use dynamic date calculation in the variant to get Month-To-Date or Previous Month date ranges. Is there a way to convert these variants to use the new FiScal calendar instead of the regular calendar?

    thanks to answer , praveen.
    I know, VARI has name of FM , but not has Calendar ID.

  • HT2513 How may I download calendar data to a spreadsheet to organize for end-of-year reports?

    How may I download 2013 calendar data to organize for end-of-year tax reporting?  I would like to work with it in Excel.

    Hi Ross,
    I thought I would go away and make you an example VI for the results xls that you have sent me.
    Here it is:  I have added a few comments here and there but if you need more info please don't hessitate to post back on the forum
    Hope if helps
    AdamB
    National Instruments
    Applications Engineering Team Leader | National Instruments | UK & Ireland
    Attachments:
    MonthExtract.vi ‏43 KB

Maybe you are looking for

  • Unable to schedule a job from the Jobs Library

    Hi, I have created and stored a job in the Job Library, however when I try and submit it to run with a schedule and against specified targets Grid just seems to hang, and eventually it comes back with "Application server is not responding". I have se

  • Question about Alpha option in the transfer rules for infoobject

    SDN Experts, I know that we check the Alpha conversion for only numbers like 0,1,2. this alpha option puts zeros in fornt of numbers but what happens when we get characters words for example 'Apple' does it put zeros infornt like '00Apple'? i will as

  • Help Creating OM Infotype

    Hi Experts, I've some doubts while creating OM infotype. I've been reading this manual http://www.sappro.com/downloads/jan07/OMinfotypes.pdf but, when I try to create the HRIXXX structure and save it I received an error from the package "Customer Obj

  • Archive Utility Quit Unexpectedly

    Every time I try to unzip a file using Archive Utility, it says "Archive Utility Quit Unexpectedly". No, relaunching it does not do anything. I have restarted my computer to no prevail and several things I've tried on the internet do not work. Curren

  • Default encoding

    Does Java pick up a default encoding from the OS? I'm having a problem copying data from OpenVMS to Linux (GenToo) via JDBC. Works fine OpenVMS to Windows, but same app gets an SQLException complaining about converting UTF-8 characters when it runs o