First Day of Year based on given 12-month date

Hi All,
i want to get first day of the given year based on 12-month financial year.
i'e if i entered '21-Sep-2014' as a given date then expected output is '01-Oct-2013'
Could you please suggest best way to get this done.
Thanks in advance.
bala krishna

Dan thanks for your reply.
am adding more description below to my post:
The thing is for a given date i needs to find out
Year Start Date , Year
End Date.
For this am using below scripts respectively
SELECT DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0);
SELECT DATEADD(DD, -1 ,DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, 0));
Here , the problem is , now its giving the current year first day and Last day.
But what i want is Year first day should be based on (minus 12 month) i'e '01-OCT-2013'
and Year End Day should be '30-SEP-2014'
i hope now the requirement is more clear.
bala krishna
Try like this
SELECT DATEADD(mm,DATEDIFF(mm,0,GETDATE())-11,0) AS StartDate,DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,-1) AS EndDate
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • First day of year and next monday of the year

    Dear all;
    Given a year, how do you determine the very first day of that year and the next two mondays for that year...

    Hi,
    user13328581 wrote:
    Dear all;
    Given a year, how do you determine the very first day of that year and the next two mondays for that year...As Sayan hinted, you can use NEXT_DAY to find the next Monday after (not the same as) a given date.
    NEXT_DAY(trunc(SYSDATE), 'MON') next_mondayis the next Monday after today. (You may not need TRUNC in the example above.)
    For the Monday after January 1 of this year:
    NEXT_DAY ( TRUNC (SYSDATE, 'YEAR')
             , 'Monday'
             )If the year happens to begin on a Monday, this will return Jaunary 8, the 2nd Monday of the year; otherwise, it will be the 1st Monday of the year.
    For the 2nd Monday after New Year's Day, add 7 to the expression above.

  • Function TODATE. Distinct first day of year

    In our Information System we have several companies and each of them has a different starting date of the fiscal year.
    For example, some start the year’s exercise on January 1st and others start on April 1st
    We want that the accumulated work commence on the basis of the beginning of the Fiscal Year, in some companies from January 1st and others from April 1st.
    All the companies are in the same information system.
    Is it possible to do this using the function TODATE?

    Hi Kelvin,
    There's an in-built SQL function to do this.
    Function Name: TRUNC
    SQL> SELECT TRUNC(TO_DATE('17-DEC-2001'),'YEAR') "First Day" FROM Dual;
    First Day
    01-JAN-01
    SQL> SELECT TRUNC(SysDate,'YEAR') "First Day" FROM Dual;
    First Day
    01-JAN-02
    For more info
    http://otn.oracle.com/docs/products/oracle9i/doc_library/901_doc/server.901/a90125/functions152.htm#79763
    Regards
    Elango.

  • Variable with low value as first day of year and high as  key date

    hi all,
                i need to create a variable with key date for which the low value should be 1st day of the year,
    means if i enter a key date (5/9/06) the values to  appear should be from 1/1/06 to  5/9/06.
    If i want the manipulation based on key date like key date + 90 etc. is it possible?
    i have written a customer exit as
    case i_vnam.
    when 'keydate'
    clear : e_t_range,
           l_t_range.
    DATA DAT(8)TYPE D.
    LOOP AT i_t_var_range INTO loc_t_var_range.
            IF loc_t_var_range-vnam = 'keydate'.
              loc_found = 'X'.
              EXIT.
            ENDIF.
          ENDLOOP.
    DAT = loc_t_var_range-vnam .
    if loc_found = 'X'.
       l_s_range-sign = 'I'.
            l_s_range-opt = 'BT'.
            CONCATENATE sy-datum(4) '01' '01' INTO l_s_range-low.
            l_s_range-high = DAT.
            APPEND l_s_range TO e_t_range.
          ENDIF.
    WILL THIS CODE WORK.
    I FEEL THERE IS PROBLEM WITH L_T_RANGE- HIGH.
    IS THERE A DICREPENCY IN THE CODE?
    IS THE CALLING SEQUENCE OF THE VARIABLE CORRECT?
    PLZ LET ME KNOW.
    THANK U ALL

    Hi,
    my mail bounced back. send vaild mail id.
    try this.
    1) create one customer exit variable say zcuvar
    2) create a USER entry variable Keydate 0date.
    3) in CMOD, in I_STEP  = 1 of zcuvar, make it default value ad 01/01/2006 as you have done.
    4) in use as range in Selection restrict.
    zcuvar;0date.
    hope i m clear.
    regards,
    San!

  • First Day of Week in Data Entry Profile

    Does anyone know if there is a standard SAP RFC i can use in my Web Dynpro application to get the First Day of Week entry in a user's Data Entry Profile?
    Thanks,
    -Kevin

    Hello Kevin,
    Function Module returns the System Date from that SAP System(R/3). I have checked this BAPI with '200743 - current week' GET_WEEK_INFO_BASED_ON_DATE, it returns proper data like Start Date and End Date.
    I Assume, you are using this in your Java WD. You can write your own function for this. This will return the day of the week.
    Calendar xmas = new GregorianCalendar(2007, Calendar.SEPTEMBER, 23);
    int dayOfWeek = xmas.get(Calendar.DAY_OF_WEEK);
    wdComponentAPI.getMessageManager().reportSuccess("Day : "+dayOfWeek);
    Note : - week starts with 0 . 0 - Monday 6 -Saturday.
    Regards,
    Sridhar

  • First day of week of given "week of year"

    Hi
    I have two values:
    - the year, for example 2007
    and
    - the week of year, for example 32
    Now i want to find out the first day of this week, which is in our locale (Switzerland) Monday, the 6th august 2007.
    How to do it?
    Thanks, Michael

    Have a look at java.util.Calendar.

  • Last day of each month in a year based on a Input date?

    Hi all,
    I have a request from a customer who wants to have a yearly report created in BEx Query Designer which starts in January up to December and they want to have a Month To Date (MDT) and Year to Date (YTD) calculation of a key figure. This report will only show one year at the time based on the date the user give as input at the Variable Screen.
    This key figure should be calculated by using the last date of each month for input when performing the MTD and YTD calculation and summarizations.
    Example:
    January: 31.01.2008  Key Figure = 1000. MTD = 1000 and YTD = 1000
    February: 29.02.2008  Key Figure = 2500. MTD = (2500-1000) 1500 and YTD = 2500
    March: 31.03.2008  Key Figure = 6000. MTD =(6000-2500)=3500 and YTD = 6000
    Etcu2026.
    This means that I have to have a lot of hidden Key figures which gets restricted on the different month end dates and formulas to calculate the different MTD and YTD results for the months as the year progresses.
    The way I have solved it now is that I have a Customer Exit which gives me the Last day of last year (Exp: 31.12.2007) based on input date and use a Offset on the last day of last year date to get the different last dates of each month.
    Since we have a leap year (one extra day in February) this year, the offset to calculate the end month dates will be different for 2007 and next year (2009). This solution is not very flexible, and it will not give the correct MTD and YTD if the customer wants to go back to 2007 and off course next year (2009).
    One solution is to create 12 Customer Exits that gives me the different month end dates (January-December), and also takes in account leap year for February for the different years. These Exits will be based on the Input date the Customers put in at the variable screen.
    I would rather want to avoid making 12 new customer exits and want your advice and expertise to find out if this is possible in any other way (maybe with only 1 customer exit) to get the last date of each month based on an input date.
    Thanks for all your advices on beforehand.
    Regards
    Oddmar Lid

    Hi,
    Thanks for you replay and documentation, but it doesn't give me excatly the functionality I'm after. The only MTD calculation code the document provides is the calculation of the following functionality:
    "Month to Date (MTD) u2013 From the 1st of month to u201CKey Dateu201D - for current year." This doesn't give the the functionality I want, which is to retrieve a given vaule for a Key Figure for the last dates of the months in a year to calculate MTD and YTD.
    This way I have created the query is to have multiple hidden Key Figures that calculates the MTD and YTD.
    In Columns in Query Designer it will look something like this:
    Selection: MTD January--> Date = 31.01.2008, Key Figure (Always Show)
    Selection: YTD January --> Date= 31.01.2008, Key Figure (Always Show)
    Selection: MTD February --> Date= 29.02.2008, Key Figure (Always Hide)
    Formula: MTD February --> MTD February - MTD January (Always Show)
    Selection YTD February --> Date = 29.02.2008, Key Figure (Always Show)
    And so on....
    This is off course a simplified version, but it shows the core of the solution. What I want to achive here is that the dates used to get the Key Figures (last date of a month) is calculated as flexible as possible, so that the users can go back and forth in time without worrying about the leap year problem and so on. I have now used an offset from the last date of last year and this is good for all the normal years, but when it is a leap year the query will use wrong dates to get the key figure vaule for the last date of each month.
    Any ideas on how to achieve this without creating 12 different Customer Exit variables (one for each end date of each month)?
    Thanks
    Regards
    Oddmar Lid

  • BI Content Variable on 0Calday for first day of the fiscal year and first day of the current month

    Hi Friends,
    In one of my BEx queries, I need to restrict a key figure for 0Calday based on the first day of the current fiscal year. And another key figure for the first day of the current month. Instead of using Customer exit, I hope there is some SAP delivered standard variable for these filters.
    Please let me know if there is anything available for this. Your answers will be highly appreciated.
    Thanks & Regards,
    Ranjan

    Hi Ranjan,
    Please find below standard variables.
    Pls check below link for more.
    Standard Variables in BEX related to Time Charcteristics
    Characteristic
    Variable
    Description
    0CALDAY
    0CWD
    Current Workday (SAP Exit)
    0CALDAY
    0CYTCD
    Cumulated to Current Day (SAP Exit)
    0CALDAY
    0DAT
    Current Calendar Day (SAP Exit)
    0CALDAY
    0DAY_***
    Cumulation of all Values to Key Date (SAP-Exit)
    0CALDAY
    0LYTCLD
    Cumulated to Current Day of Previous Year
    0CALDAY
    0LYTCLD
    Previous Year Cumulated to Current Day (SAP Exit)
    0CALDAY
    0L_DATE
    Last Calendar Date
    0CALDAY
    0P_LY_R
    Comparative Period for Last Year
    0CALDAY
    0P_TY_R
    Period for Current Year up to Yesterday
    0CALDAY
    0S_KDATE
    Key Date Interval for Previous Year (SAP Exit)
    0CALDAY
    0S_KDAY
    Key Date Interval Current Year (SAP Exit)
    Best,
    SATYA.

  • FM for First day of the Fiscal Year.

    Hi ,
          i want to calculate First day of the Fiscal Year ,please send me the FM name urgently.
    Thanks  in advance

    hi,
    BAPI_CCODE_GET_LASTDAY_FYEAR
    this will give you back the last day of a fiscal year for a company code, but if you start with previous year, than you add 1 to the result, than you get first day of current fiscal year.
    FIRST_AND_LAST_DAY_IN_YEAR_GET
    this will give you back the first and the last dates of a given year, but you'll need the period version as well.
    hope this helps
    ec

  • Multi-day events only showing up on first day of event in year view

    There are several things about iCal that I find annoying (makes me miss my old Palm PDA sometimes), such as being able to set my own default meeting times, meetings being defaulted to all-day, no way to connect a contact to the event without having to invite them to join (my old Palm did this and it was a very useful tool). Each of these has many discussions already on these topics with a solution (except adding a contact to an event), such as simply typing in the meeting time when you setup the event.
    However, I can't find a discussion on the following question, and therefore no solution. Hope someone out there knows the answer:
    Why do Multi-day events only show up on the first day of the event in year view, and is there a way to change it?
    Thanks in advance!

    Greetings,
    Perhaps I'm not setting up my events as you are but I see a color for each day of my multi-day event.
    My steps:
    1. Add a multi-day event to iCal:
    2. Switch to Year view and observe the matching date range (26th - 29th):
    Suggestions:
    Make sure you have all your updates installed (Apple > Software Update).
    Toggle the "all day" check box for the events in question and see if that makes the events show up in Year view.
    If that doesn't help, please provide a screen shot of the edit window of the event in question so we can see how you have it configured:
    Cheers!

  • How to find first day of the year

    Big picture: trying to determine how many pay periods are left in the year. There are 52 weeks in a year, and our company pay out each week.
    The first pay week of the year always starts on a Friday. So If Janurary 1 is a friday, then the 1st week of pay period starts that week. If Jan 1 is a Thursday, then the first pay week will start on Janurary 2.
    I need to figure out what day the first day of any year it is. By day, i mean Mon, Tue, Wed, Thur, Fri, Sat, or Sun.
    Then when I figure out what day it is, i will write an if/then statement saying if Jan 1 is a monday, then add 4 days to that date and that will be the first day of a pay period.
    Then when i figure out the first day of the first week, I wanted to add 7 days to create week2, week3.... week 52.
    Then take todays date and if it was between week x and week y, then it would determine that z many pay periods are left...
    is this the best way to go about this? anything easier?

    You can use the getDay method of a Date object to determine the day of the week. Any decent JavaScript reference will have more information.
    George

  • How to get the date of first day of a week for a given date

    Hi gurus
    can any one say me how to get the date of first day(date of Sunday) of a week for a given date in a BW transformations. For example for 02/23/2012 in source i need to get 02/19/2012(Sunday`s date) date in the result. I can get that start date of a week using  BWSO_DATE_GET_FIRST_WEEKDAY function module. But this function module retrieves me the  start date as weeks monday(02/20/2012) date. But i need sundays(02/19/2012) date as the start date. So it would be really great if anyone sends me the solution.
    Thanks
    Rav

    Hi,
    The simplest way would be to subtract 1 from the date date which you are already getting in transformation routine, but instead of doing that subtraction manually which might need bit of errort, you can simply use another FM to subtract 1 from given date.
    RP_CALC_DATE_IN_INTERVAL
    Regards,
    Durgesh.

  • Need the first day of the year and last day of the year.

    hi all,
    i need a function module which can get me the first day of current year and last day of the current year??
    please help.

    Similar date questions are being asked ALL THE TIME.  Please search.

  • First day of current month, one year ago

    All,
    Does anyone have a calculation or know how I can calculate the first day of the current month, one year ago? I am trying to setup a filter criteria to show all records created >= 1st day of current month for prior year and <= the last day of the prior month. I have the second half of the equation for last day prior month but need some help on the first half.
    Thanks in advance for any pointers!
    D

    You can try:
    SELECT TRUNC(ADD_MONTHS(sysdate, -12), 'MON') FROM dual;
    Or
    SELECT TRUNC(sysdate-NUMTOYMINTERVAL(1,'YEAR'), 'MON') FROM dual;

  • How to get the First day in a Week in a Fiscal Year

    Hi guys,
    I have a Requirement to calculate the First day in  a Week  in a Fiscal year .
    The FM GET*FIRST_DATE and all are for Calender year.
    Is there any FM to calculate the First in a Week in a Fiscal year.
    For eg. They will give 200826.
    In this 26 is the Week.
    I need to find the First date value in that Week.
    Thanks,
    Gokul

    Hi Gokul...
    Instead of using the funtion module you can just write the 3 statements of code to get the first day of the week.
    Its similar to the above one but instead of writing case statement you can achive the following.
    data : w_res type i,
             w_data type d,
    w_res = w_date mod 7.
    w_date = w_date - w_res.
    write w_date.
    This works.
    Regards,
    Siddarth

Maybe you are looking for

  • Suddenly prompted to activate iPad Air in use for over a year, never been used for betas or jailbroken

    Last night I turned on my iPad Air to a message that read I needed to activate my iPad.  I went through the steps (selected a wifi network and entered my Apple ID password).  IT spun for several minutes before saying it was unable to activate, try ag

  • Cannot Access WRT54GL Config Page

    I am doing some consulting work for a small business and cannot gain access to the routers configuration page.  Here is a summary of the environment: * WRT54GL, ver. 1.1. * The WAN port of the router is connected directly to the Verizon DSL modem for

  • BT email address and Joomla! settings

    Hi all, please help as nothing I've tried seems to work. I've built a site in Joomla! and have now created a form. I should be receiving emails from anyone filling out the form but am not and despite filling in all permutations I can think of I can't

  • Connecting iBook G4 to projector

    I want to connect an iBook G4 to an Epson projector. How do I do it? The projector has a blue multipin socket as standard and a plug in card, presumably for wireless networking. My Pogue manual does not mention projectors at all. I suspect I have to

  • Using view as a sql query in odisqlunload

    Hi Expert, I tried sql query in osisqlunload but that query retrieving the data from a view,even operator log shows successful execution data,but data is not getting into text file...... Is Odisqlunload supports views as sqlquery? cheers, surya Edite