Date Formula??

Post Author: mklafert
CA Forum: Formula
I am writing a report that will compare monthly sales.  Example Jan 06 to Jan07 .  I have fields called This year sales for period 1, This year sales for period 2 etc.  I also have fields called last year sales for period 1, Last year sales for period 2, etc.  I want all Tweleve months on the same report.  I assume I must write a formula that when I want to compare teh sales for the indiviual months for the whole year of 07 then it will print the this year sales for period 1-12 and last year sales for period 1-12  but like the example below:
Jan 06   feb06   march 06 etc
2,000    3,000     4,000
Jan07  Feb 07  March 07
4,000  2,000      3,000
I am doing this in excel I have one row for the 1st year jan 06-dec 06.  Then on the second row jan 0-dec 07.  If necesary I guess I could do :
Jan 06 jan07 then I wil lhave a formula that will figure out the percentage difference in sales.  Hope this is clear.  Thanks for any Help In Advance.

Use datepart() function to calculate age:
For help take a look at link
http://www.sql-server-helper.com/tips/tip-of-the-day.aspx?tkey=62abfa55-b96d-42da-8083-e2adfbb13476&tkw=uses-of-the-datepart-date-function
 DECLARE @BirthDate    DATETIME
SELECT DATEPART(YYYY, GETDATE()) - DATEPART(YYYY, @BirthDate) - CASE WHEN DATEPART(MM, GETDATE())  > DATEPART(MM, @BirthDate) OR
                (DATEPART(MM, GETDATE())  = DATEPART(MM, @BirthDate) AND
                 DATEPART(DD, GETDATE()) >= DATEPART(DD, @BirthDate))
            THEN 0 ELSE 1 END AS [Age]  
Please click "Propose
As Answer" if a post solves your problem, or "Vote
As Helpful" if a post has been useful to you

Similar Messages

  • Date formula variable with replacement path.

    Hi ,
    I have date formula variable with replacement path.
    Variable pop up with date format yyyymmdd. but i want dd.mm.yyyy.
    I have checked my user profile setting and it is dd.mm.yyyy.
    Can u please suggest it .
    Thanks
    Pramod

    Thanks for the rely , but basically i need a variable only for selection.
    thats why i have created formula variable processing my cutomer exit.
    But i think customre exit variable comes with text format .
    any1 has an idea for the same.
    Thanks
    Babu

  • Date Difference between to date formula variable

    Hi Expert,
                    I have create two formula variable one for Document Date and another one for Goods reciept date
    and through formula variable I am subtracting these two formula variable and getting the no. of days between
    document date and GR date.
    This Shows me the correct value for one document date because i am filtering my query according to document
    date,
    while i am giving the date range for document date is shows me incorrect result. bucause document date formula
    variable contains only one date.
    Eg. i am giving the document date range like 01.02.2010 - 28.02.2010.
          In document date formula variable it contains only 01.02..2010 and GR date formula variable it contain correct
    value, thats why the date difference is incorrect because those PO which has PO date like 12.02.2010 for that Doc
    formula variable bring the same date like 01.02.2010.
    Please tell me the solution
    Thanks and Regards
    Lalit Kumar

    Hi Expert,
                     Actually i have created two formula variable on for PO date and another for GR date
    and i've restrict the query through PO date.
    while i am taking the single PO date in Selection parameter it showing me correct difference
    eg: Selection Parameter for PO: 01.01.2010
    But while i am taking the date interval for PO date
    eg: 01.01.2010-30.01.2010
    PO No: XXXXX123 , Doc date: 01.01.2010 GR date: 7.01.2010 then date difference is : 6
    PO No: XXXXX432, Doc date: 03.01.2010 GR date: 8.01.2010 then date difference is : 7 but it is 5
    Thanks and Regards
    Lalit Kumar

  • Creating a Fiscal Date formula

    I have created a Crystal Report and wrote a formula that allowed me to match my database entries to my fiscal months.  However, my subsequent year to date formula based off my month to date formula will only bring in current month data.  It won't bring in previous month data.  Is there an easy method within Crystal Reports to set the MonthtoDate function to a fiscal month?  Or a formula that will use the MonthtoDate function based on a fiscal month rather than a calendar month?

    Ian,
    Formula below selects the cost to use for the current month costs.  It works well.
    if ({@Cur_Mon})= "January" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "February" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "March" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "April" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "May" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "June" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "July" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "August" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "September" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "October" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "November" then {COST.TOTAL}
    else if ({@Cur_Mon}) = "December" then {COST.TOTAL}
    Formula below creates "Cur_Mon".  Selects the dates that the costs were incurred correctly into the fiscal month.
    if {@Fiscal_Month}in DateTime(2011, 01, 01, 0,0,0) to DateTime(2011, 01, 29, 0, 0, 0)
    then "January"
    else if {@Fiscal_Month} in DateTime(2011, 01, 30, 0, 0, 0) to DateTime(2011, 03, 05, 0, 0, 0)
    then "February"
    else if {@Fiscal_Month} in DateTime(2011, 03, 06, 0, 0, 0) to DateTime(2011, 04, 02, 0, 0, 0)
    then "March"
    else if {@Fiscal_Month} in DateTime(2011, 04, 03, 0, 0, 0) to DateTime(2011, 04, 30, 0, 0, 0)
    then "April"
    else if {@Fiscal_Month} in DateTime(2011, 05, 01, 0, 0, 0) to DateTime(2011, 06, 04, 0, 0, 0)
    then "May"
    else if {@Fiscal_Month} in DateTime(2011, 06, 05, 0, 0, 0) to DateTime(2011, 07, 02, 0, 0, 0)
    then "June"
    else if {@Fiscal_Month} in DateTime(2011, 07, 03, 0, 0, 0) to DateTime(2011, 07, 30, 0, 0, 0)
    then "July"
    else if {@Fiscal_Month} in DateTime(2011, 07, 31, 0, 0, 0) to DateTime(2011, 09, 03, 0, 0, 0)
    then "August"
    else if {@Fiscal_Month} in DateTime(2011, 09, 04, 0, 0, 0) to DateTime(2011, 10, 01, 0, 0, 0)
    then "September"
    else if {@Fiscal_Month} in DateTime(2011, 10, 02, 0, 0, 0) to DateTime(2011, 10, 29, 0, 0, 0)
    then "October"
    else if {@Fiscal_Month} in DateTime(2011, 10, 30, 0, 0, 0) to DateTime(2011, 12, 03, 0, 0, 0)
    then "November"
    else if {@Fiscal_Month} in DateTime(2011, 12, 04, 0, 0, 0) to DateTime(2011, 12, 31, 0, 0, 0)
    then "December"
    else "Frog-guts"
    Fiscal_Month actually compares two date fields in the database and uses the one which is not empty.
    The formula below is my "Year to Date" formula.  I've tried several different ways to write it, but it just mimmicks my current month formula.
    In the end is just is a simpler way to write my first formula above.  How can I make my year to date formula add all the costs that have occured to date?
    if ({@Cur_Mon}in ["January", "February","March","April","May","June","July","August","September",
    "August","October","November","December"]) then {COST.TOTAL}

  • DATE formula bug

    Hello everyone,
    As i said in subject, I have a problem with a DATE formula. It's funny I think but it may be a little problem in the future. My date which should be ok is not. Year and month is ok but day is tricky because I have to put an expression after a DAY (-2). If I don't a date is 2 days later from the one that I want to make. If anybody can help me fix this I really appreciate that.
    Thanks in advance.
    Message was edited by: adpa15

    Is it so tiring to read carefully the available resources ?
    As you may see, Apple took time to give us the needed infos.
    Given what we may read in the forums, it seems that users are more often buggued than the applications themselves
    Yvan KOENIG (VALLAURIS, France) vendredi 19 mars 2010 19:28:43

  • Date Formula variable

    Dear All,
    I have created Date formula variable and i have applied some exception aggregation on that to find Last bill date.
    Now i am creating formula and applying following condition :
    ((If quantity > entered quantity) AND (Quantity2 ==0) ) * Sale date whr Sale date is exception aggr on date formula variable.
    But when i apply this date format is changed to Number format.
    Plz help ASAP.
    Regards,
    SS

    I am using Billing date so it has reference to 0DATE.
    So in this case how do i achieve this?

  • Issue with date formula when running a report on the 1st day of the month

    We have a formula that compares last month data against last year last month, the report runs on the 1st of every month although the report errors when it tries to run in January being the first month of the new year it tries to look for a month begining with Zero instead of looking back at decemeber which would be 12.
    Does anyone any solutions for this issue?
    Thanks,
    Chris
    Example of some formula's we have tried but none seem to work.
    if {@MonthName} = "December" then year({CDCCHD.CDOPDT}) in year(currentdate)-1 to year(currentdate)-2 else year({CDCCHD.CDOPDT}) in year(currentdate)
    OR
    (if {@Last Full Month Name}= "December" then year({CDCCHD.CDOPDT})= year(currentdate)-2 or
    {CDCCHD.CDOPDT} in lastyearytd else {CDCCHD.CDOPDT} in lastyearytd or
    {CDCCHD.CDOPDT} in yeartodate)
    OR
    ({CDCCHD.CDOPDT} in dateserial(year(currentdate)-1,month(currentdate),01)-1 to dateserial(year(currentdate)-1,month(currentdate)-1,01) or
    {CDCCHD.CDOPDT} in lastfullmonth)
    OR
    if {@monthname} = "December" then {CDCCHD.CDOPDT} in dateadd("m", -28, (currentdate)) to (currentdate)-14 else {CDCCHD.CDOPDT} in dateadd("m", -14, (currentdate)) to (currentdate)

    Chris,
    Give these formulas a try...
    Beg of Last Month
    DateAdd("m", DateDiff("m",#1/1/1900#, CurrentDate) - 1, #1/1/1900#)
    End of Last Month
    DateAdd("m", DateDiff("m",#1/1/1900#, CurrentDate), #1/1/1900#)
    Beg December of Last Year
    IF DatePart("m",CurrentDate) = 1
    THEN DateSerial(DatePart("yyyy",CurrentDate) -2, 12,1)
    ELSE DateSerial(DatePart("yyyy",CurrentDate) -1, 12,1)
    End December of Last Year
    IF DatePart("m",CurrentDate) = 1
    THEN DateSerial(DatePart("yyyy",CurrentDate) -1, 1,1)
    ELSE DateSerial(DatePart("yyyy",CurrentDate), 1,1)
    Note that the "End" formulas produce a value that shows midnight of the following day that you would normally expect to see... For example, if you are expecting to see 12/31/2009, it will show 1-1-2010.
    The reason is that the formulas come out to be midnight of the day shown... So a range of 12/1/2009 - 1/1/2010 will include 12/31/2009's data but none of 1/1/2010... (12/1/2009 - 12/31/2009 would actually cut off 12/31/2009).
    If for some reason your data is stored w/o time values then an adjustment would need to be mande.
    HTH,
    Jason

  • Excel 2013 Powerpivot datamodel error with DATE formula

    Hello forum users and Excel guru's alike.
    I have a question relating the datamodel in Excel 2013 Powerpivot. I am using a Dutch version of Excel (on Office 365) but formula's in Datamodel are all in English so I think most of you will understand the issue:
    What I want to do: Take a date and adjust this date to incorparate a number of months that is added in a other column.
    Example:
    Start of contract date: 24-5-2014 (this is a date field in the datamodel and it is called [StartContract])
    Contract duration in months: 10 (this is a number field in the datamodel and it is called [DurationInMonths])
    Output: 24-03-2015
    (this is the calculated field that doesn't work)
    My current formula looks like this:
    =DATE(YEAR([StartContract]);MONTH([StartContract]+[DurationInMonths]);DAY([StartContract]))
    It shows an error as soon as I hit Enter. The formula works fine when I replace [DurationInMonths] with the value "10" or when I leave out "+[DurationInMonths]". But that isn't an option!
    The following variation also doesn't work.
    =DATE(YEAR([StartContract]);MONTH([StartContract])+[DurationInMonths];DAY([StartContract]))
    Please, is there any one with a solution?
    Kind regards,
    Erik van Hurck

    Hi Tony,
    I have tried your solution, to no succes I am sad to say.
    I do agree that the formula works in Excel, but now switch over to the
    PowerPivot Data model and try the formula there. And it will repport an error:
    =DATE(year([StartDate]);month([StartDate]+[DurationInMonths]);DAY([StartDate]))
    is the formula I used in the Datamodel.
    The DurationInMonths field is:
    Whole numbers and formatted as: General
    The StartDate is:
    Auto (Date) and formatted as: Short Date
    For more Information I get this error:
    Cannot query internal supporting structures for column "EndDate" because they depend on a column, relationship, or measure that is not processed. please refresh or recalculate the model. Maybe this link will help further:
    http://office.microsoft.com/en-au/excel-help/upgrade-power-pivot-data-models-to-excel-2013-HA103356104.aspx

  • Date Formula In Detail Selection

    Hello
    I'm really new to business objects and could really do with some advice.
    I have to use Business Objects 6 although, judging by what I have seen from this website, it is quite old!
    I have selected the universe that I need, I have selected the fields that I need and my report is working perfectly.  So far so good.
    Now, what I would like to do is automate my report so that it will run over night but (and this is the bit that is giving me trouble), I would like it to run everynight but only run sales that were keyed on for 62 days from todays date (whatever today's date may be).  This is so that it can run over the weekend without anyone logging in and having to physically run it.
    I know that I need to do this in the first screen where I select my criteria but I can't seem to get it to accept a formula, it's seems to only want to set it up as a prompt.
    Also, if anyone has any advice on getting it to automatically email the file out in .csv format, that would be great too!
    Sorry if I am asking for the moon on a stick!!!
    Any help on this would be fantastic.
    Many thanks
    Claire

    Claire,
    I don't think you're asking for the moon, but what you are asking to do would best be handled as a filter within your universe (the filter is added via Designer).  Once the filter is built you would add it to your DeskI report (just drop it in the filter pane while you're editing "Edit Query" mode...).  You have a good business statement, sales that were keyed on for 62 days from todays date, which should be easy enough for an experienced universe builder person to accommodate you ... good luck.
    thanks,
    John

  • Search on Maximum Date Formula Field

    Hello All,
    I am trying to create a report that will return a PART table linked with an outer join to an ORDERDTL table.
    What I would like to do is to return only the Maximum (or last) order date for each part and then have a parameter field that will give me a cutoff date for the last ordered.
    For example:  Part ABC was ordered on 1/1/08 and 1/1/07.  Part XYZ was ordered on 1/1/07 and 1/1/06.  When I enter a cutoff date of 2/1/07 it should return part XYZ but NOT part ABC because ABC was ordered after the cutoff date.
    I can see the parameter being "only return the parts with a maximumdate NOT > parameterdate".  I am having trouble getting the maximum date to be available for query. 
    How do I run a date parameter field against a Formula field with a maximum date?
    Any other pointers?
    Thanks,
    Ross

    you need to create a formula MAXIMUM(DATE) i would have it subtotal on a group, i guess your part #.
    then in the selection criteria, in the group selection you can use that or use a conditional surpression based upon the parameter

  • Date formula variable in BEx output

    Dear All,
    In Bex , I made a formula variable F_CURDATE and used it in formula. I fill it with current date
    l_s_range-low = sy-datum.
    My value in BEx comes 201,40,604. This is 04 Jun 2014.
    Why isn't it coming in date format. I then, used data function [date]'process value as date. The output shows value X.
    How can I show  date in date format in BEx?
    Regards,
    cleo

    Hi Cleo,
    The bit l_s_range-low = sy-datum must be coming from the customer exit code, right?
    And should this code not be used for populating a cust exit variable? How do you populate sy-datum to a formula variable in the query? Pls correct me if i m missing something in your question.
    However if it is a formula variable on 0CALDAY, there are standard SAP variables giving current date.
    Can you not use them in your query as per your requirement?
    Regards,
    Srilakshmi B

  • Excel date formula????

    Hi,
    I am a complete novice at Excel and need help with converting a date with an English layout (30/12/2013) to an American layout with 00.00.00 next to it. So i want to create 12/30/2013 00.00.00. How can i do this using a formula and apply to a column of dates?
    Thanks. 

    I suspect there is necessary information you have not provided.
    But if the dates are "real" Excel dates, and you want to do this with a formula, then merely
    =TEXT(A1,"mm/dd/yyyy ""00.00.00""")
    If the dates are text strings, or a mix of text strings and real dates, or if you want the 00.00.00 at the end to be more than just a text string, or if you want the date to be something you can operate on, then the solution will be more complex.  But
    I will wait to provide that, pending clarification from you.
    If they are a mix, then you can first select the column; use the data text-to-columns wizard, and when you get to step3, select date and DMY format.  That should convert them all to "real dates" and allow you to apply the above formula.
    To tell if the date is a text string, or a real date, test it to see if it is a number (e.g. =isnumeric(a1)).  Excel stores dates as serial numbers with 1 = 1 Jan 1900.
    If you want the 0's at the end to represent something (e.g. hrs/mins/seconds), rather than just being a text string, let us know. 
    Ron

  • Date formula to convert 2015-06-07 00:00:00.000 to Jun-15

    Hi All;
    I have a date in the format
    new_duedate =
    2015-06-07 00:00:00.000
    i need to convert it to Jun-15
    I am currently using below  formula
    CONVERT(CHAR(4), (new_duedate), 100) + CONVERT(CHAR(4), (new_duedate), 120)
    which converts into Jun 2015
    Any help much appreciated
    Thanks
    Pradnya07

    Lots of ways
    FORMAT(datefield,'MMM-yy') (sql 2012)
    REPLACE(CONVERT(varchar(6),datecolumn,6),' ','-')
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Most recent date formula

    I need the formula to calculate the most recent date.

    Hi,
    Just go to the formula fields and create New formula.write folowing formulae.
    Maximum(Your Date Field)
    Regards
    Kiran

  • MS Project 2010 Date Formula

    Please someone help, i can get this formula to work in Excel 2010 when i replace "[Start]-[Current Date]" with cell numbers that contain dates.  I have tried multiple time to get this converted to MS Project 2010 as a custom field formula. 
    Can anyone help me understand how to make this formula work in Project.
    =IF(([Start]-[Current Date])<=14,"T-2W",IF(AND(([Start]-[Current Date])>14,([Start]-[Current Date])<=28),"T-4W",IF(AND(([Start]-[Current Date])>28,([Start]-[Current Date])<=56),"T-8W",IF(AND([Start]-[Current Date])>=56,"T-12W"))))
    I am attempting to nest "IF" commands to automatically calculate planning status tollgates in Project, "T-2W", "T-4W" etc...

    Hi,
    First of all, you have to replace IF by IIF.
    Then you do not need the AND condition.
    IIf(([Start]-[Current Date])<=14;"T-2W";IIf((([Start]-[Current Date])<=28);"T-4W";IIf((([Start]-[Current Date])<=56);"T-8W";"T-12W")))
    Finally, if it is still not working, depending on your regional settings, try to change the comma (,) by a semi-colon (;).
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

Maybe you are looking for

  • In XML Show Form display Creator FirstName and LastName ?

    Hi all, In XML Form Builder i want to display the creator FirstName and LastName ( Diamond Admin) in the Show Form. For egs: Logon ID: diamond_admin Last Name: Admin First Name: Diamond In the EDIT Form By using $sap_user and also createdBy property

  • Can't print to edge of #10 envelope

    I'm using Adobe ReaderX 10.1.9.  When I print a #10 evelope to my MFC 6710DW Brother Injet there is a 13/16" margin which cuts off about 25% my return address on the left edge of the envelope.  How do I get it to print to the edge of the envelope or

  • Using "Enum constant" in state machine.

    hallo all. i bild state machine, with 10 states. i move beetwen the states with Enum constant. my qustion is: if i want to add/delete some  states, why i need to update the Enum constant at every state ? there is  way to update "Enum constant" at one

  • [LV8.2] "Export string" (captions) strange behaviour

    Hi, I have 2 VIs. One was made with previous versions of LV (called A), and then re-opened and saved with LV8.2, the other was born in LV8.2 (called B). All is ok. I have some "system checkbox" controls in them, I didn't check the "show caption" and

  • A/C Assignment

    Hi, We have created a new mat type 'zmat' (Spares).  Now the requirement is that to assign new G/Ls as follows: Inventory G/L - 12345 Consumption - 23456 How we assign the above G/Ls (as these are different G/Ls for spares), what are the steps. Thank