Get Previous Working Day

Do you know any function module which will give me the previous working day only by ignoring saturdays and sundays and it should NOT consider holidays.
Example:
Monday's Date should give me previous friday's date.
Friday's Date should give me previous thrusday's date

Hello Ramesh,
I assume you have your factory calendar ID with you:
DATA:
    L_V_PREDT        TYPE DATUM, "Next Day.
  L_V_PREDT = SY-DATUM - 1.
* Get the next Working Day as per Factory Calendar
  CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
    EXPORTING
      CORRECT_OPTION               = '-' " -VE  to get the previous date
      DATE                         = L_V_PREDT
      FACTORY_CALENDAR_ID          = 'HY' "--> Give your factory cal. ID here
    IMPORTING
      DATE                         = V_PREWD
    EXCEPTIONS
      CALENDAR_BUFFER_NOT_LOADABLE = 1
      CORRECT_OPTION_INVALID       = 2
      DATE_AFTER_RANGE             = 3
      DATE_BEFORE_RANGE            = 4
      DATE_INVALID                 = 5
      FACTORY_CALENDAR_NOT_FOUND   = 6
      OTHERS                       = 7.
  IF SY-SUBRC <> 0.
*  Do Nothing
  ENDIF.
If you want to use the FM: BKK_GET_PRIOR_WORKDAY, still then you have to use the operation:
L_V_PREDT = SY-DATUM - 1.
And pass L_V_PREDT to the FM. You can test with 23.03.2009 date & check )
Hope this helps.
BR,
Suhas
Edited by: Suhas Saha on Mar 19, 2009 4:56 PM

Similar Messages

  • How to get the last(latest or previous) working day

    hi,
    using sysdate we may be getting today's date and sysdate-1 will be fetching the yesterday's date. but if sysdate-1 turns to be sunday or a holiday then we need to get the previous date to that holiday date .THe list of holidays are in lt_list_holidays. The Holiday date shall be the holiday_date column. I need a query which displays the last (latest or previous) working day ..
    Please advice
    Edited by: vine on Jul 20, 2010 5:30 AM
    Edited by: vine on Jul 20, 2010 5:51 AM

    Hi,
    vine wrote:
    hi ,
    THe queery seems to be fine but in the middle if we have any holidays and the holidays are in lt_list_holidays table . the name of the holiday date is holiday_date in lt_list_holiday.Is the name of the holiday important? I'll assume not. I'll also assume you have a column d (a DATE) that is the date of the holiday.
    >
    Please adviceThat's quite a different problem from what you first posted.
    Instead of posting a question x, waiting for someone to answer it, and then saying that the problem is really y, don't you think it would be better to post question y in the first place?
    You can do something like this:
    WITH     prev_days     AS
         SELECT     TRUNC (SYSDATE) - LEVEL     AS a_date
         FROM     dual
         CONNECT BY     LEVEL <= 4     -- worst case (see below)
    SELECT     MAX (a_date)     AS previous_work_day
    FROM     prev_days
    WHERE     TO_CHAR (a_date, 'Dy', 'NLS_DATE_LANGUAGE=''ENGLISH''')
                   NOT IN ('Sat', 'Sun')
    AND     NOT EXISTS ( SELECT  1
                   FROM    lt_list_holiday
                   WHERE   d     = prev-days.a_date
    ;Where I work, holidays are never consecutive, in fact, they are always at least 7 days apart, so I can be sure that a period of 4 consectuive days will always contain at least one work day. (There may be two weekend days plus one holiday; that's the worst case.) If you can have two or more holidays in a row, or holidays spaced 3 days apart (so that one might fall on a Friday, and the other on Monday), then increase the "magic number" 4 in
         CONNECT BY     LEVEL <= 4     -- worst caseto something appropriate. If you put it too high (say 10), no serious harm is done.

  • Could not get Previous Week Day starting today

    I need help  to get PREVIOUS WEEK day starting today.
    Eg:
    Today is 15 / 09 / 2011
    I need Date 08 / 09 / 2011
    Hence both 15th and 08 are Thursday. One is today's thursday and other is previous week thursday.
    Regards

    Warranty on iPhone is not international, but valid only in country of
    original sale. Since you purchased the iPhone in Australia, your warranty
    is valid only in Australia. You must either personally return the iPhone
    to Australia for evaluation and possible replacement or sent it to someone
    in Australia to take into Apple for the evaluation. Apple will not accept
    international shipments for repair nor will Apple ship out of the country
    after replacement.
    Sorry to be the bearer of this news, but it is the way iPhone warranty and
    replacement has always worked.

  • Query to retrieve previous working day?

    I need to write a query that will retrieve the previous working day. Therefore, it must exclude weekends and holidays.
    For example, the previous working day for Saturday, February 19 or Sunday, February 20 would be Friday, February 18. And since Monday, February 21 was a holiday for us then the previous working day would also be Friday, February 18.
    I've found some queries that allow me to find the previous working day excluding weekends, but I'm having difficulty with the holidays aspect. We have a table called CORPHOLIDAY that contains a field HOLIDAY that stores the holiday dates.
    Can I do this with a simple query? I'm not proficient with Oracle, so any and all help is appreciated. Thanks!

    Welcome to the forum!
    As Dan said, whenever you have a question, it really helps if you post CREATE TABLE and INSERT statements to create whatever tables you need, so people can re-create the problem and test their ideas. Also post the results you want from that data, and your version of Oracle.
    The sample data might be as simple as this:
    CREATE TABLE     corpholiday
    (     holiday     DATE
    INSERT INTO corpholiday (holiday) VALUES (DATE '2011-02-21');Here's one way to get the results you want. You enter a starting date (such as February 22, 2011) and the query produces the last working day before that date (in this case, February 18).
    WITH     consecutive_days     AS
         SELECT     TO_DATE ( '22-Feb-2011'     -- Input parameter
                   , 'DD-Mon-YYYY'
                   ) - LEVEL     AS a_date
         FROM     dual
         CONNECT BY     LEVEL     <= 4     -- 1 + Max. possible non-work days
    SELECT     MAX (a_date)     AS prev_work_day
    FROM           consecutive_days     c
    LEFT OUTER JOIN      corpholiday          h  ON     c.a_date     = h.holiday
    WHERE     TO_CHAR ( a_date
              , 'Dy'
              , 'NLS_DATE_LANGUAGE=ENGLISH'     -- If necessary
              )     NOT IN ('Sat', 'Sun')
    AND     h.holiday     IS NULL
    ;What you might really like for this job is a WHILE loop, something that would start at the given date, subtract one, test if that day was a work day, and, if necessary, repeat until it did find a work day. That's how you might do it in a procedural language, like PL/SQL, and that's exactly what a lot of people would do: write a PL/SQL function, that could us a WHILE loop. SQL is a non-procedural language, so it doesn't have anything like a loop. Using a CONNECT BY query, as shown above, we can simulate the behavior of a FOR loop, where we do a fixed number of iterations. The query above works by using CONNECT BY to generate the last 4 dates before the given starting date. What is that magic number 4? It's the worst case of how many consecutive days there can be (at least where I work) that is sure to have at least one work day. Where I work, holidays are always at least a week apart, so the longest you can go without a work day is like the example you gave: a Monday (or Friday) holiday, adjacent to the 2 weekend days. You may need to change the number 4 to something higher if, say, December 25 and 26 were both holidays, or if Good Friday and Easter Monday were both holidays.
    As posted, the query above works in Oracle 9 (and up), but it can be modified for earlier versions.
    Edited by: Frank Kulash on Feb 23, 2011 8:57 PM
    Added explanation

  • Need to get available working day

    Hi All,
    I'm using oracle 9i version.
    i have a procedure which will take 1 in parameter and 1 out parameter.
    we will pass one inputdate
    now the date which i passed is sunday or holiday then we have to return the next working day that holiday list i'm getting form holiday_list table.
    now the problem is suppose i passed a date which is sunday so now i have to return like the inputdate+1 so that it will be monday . but now i need to check weather that monday also holiday or not in the holiday list
    if it is then i have to go for next like INputdate+2 again there also i have to check the same for this till i get a available date .
    can some suggest how to handle this problem.
    Thanks in advance
    -RG

    SQL> select * from holidays;
    DT
    01-JUL-07
    11-JUL-07
    02-JUL-07
    07-JUL-07
    SQL> exec :your_date := '07-jul-2007';
    PL/SQL procedure successfully completed.
    SQL>  select min(dt) dt
      2   from(
      3     select trunc(to_date(:your_date,'dd/mm/yyyy')) + level - 1 dt
      4     from (select case when count(*) <= 8 then 9 else count(*) end cnt
      5         from holidays
      6         where dt >= trunc(to_date(:your_date,'dd/mm/yyyy')))
      7     connect by level <= cnt
      8     )
      9   where to_char(dt,'fmday') != 'sunday'
    10   and dt not in(select dt
    11                 from holidays
    12                 where dt >= trunc(to_date(:your_date,'dd/mm/yyyy')))
    13   /
    DT
    09-JUL-07
    Message was edited by:
            jeneesh
    curved path......                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Get Nexr working day for the given calendar id

    Hello,
    My requirenment is I have a  date.If that date falls on friday then I have to get the next working day date i.e.Monday for the given Calender iD

    DATA:wk_dat TYPE scal-indicator.
    PARAMETERS:pa_dat TYPE sy-datum.
    CALL FUNCTION 'DATE_COMPUTE_DAY'
      EXPORTING
        date = pa_dat
      IMPORTING
        day  = wk_dat.
    CHECK wk_dat = 5.
    pa_dat = pa_dat + 3.
    WRITE pa_dat.
    here if u want to get the next working day
    Use FM DATE_CHECK_WORKINGDAY after the check statement.
    add the date until u find a working day.

  • IMovie auto-updated me, can't get previous work uploaded

    So I was working on a project and when I tried to open iMovie it said I cannot open it nless I update - but if I were to click open then the new update would not allow me to access any old work.
    - The problem is that I don't know if I should just download the iMovie version I had previously?
    - Even if I were to, how would I know which version I needed to re-download (ie: which version I was using previously when started the project)?
    - Is there another way around it?
    My work is saved on an external hard drive (Lacie 500gb) and my computer is a Macbook Pro version 1 purchased in July 2006.
    The version of iMOvie I have now is 6.0.3. - so which version came with the Macbook Pro version 1 in summer 2006??

    Welcome to the forum.
    I suspect iMovie isn't telling you to update the iMovie application. To the best of my knowledge, it never does that when we launch iMovie.
    Rather, it may be telling you is that the project you're trying to open was created in an older version of iMovie and that to edit it, the project must be updated.
    Don't do that now, not until you rule out other possible problems. iMovie may be confused.
    First, check that the drive the project resides on uses the Mac OS Extended disk format. If not, iMovie can't reliably read and write to the disk, which may be causing some confusion. Here's more about checking the format.
    http://discussions.apple.com/message.jspa?messageID=4176921#4176921
    Updating the project when the disk format is improper may cause project problems, so you want to rule that out.
    If this doesn't sound right please tell us exactly what iMovie says when you open the project.
    Karl

  • To get working day

    Hi Gurus,
         my requirement is to get a working day.
    I know how many days my work will take to finish i.e no of days, let us say 10 days
    I need to add these number of working days to the system date excluding the weekend days.i.e I need to add 10 working days to the system date.
    Any help is appreciated...........
    Thanks,
    Sudhaaaaaaaa........

    Do like this:
    DATA: it_psp TYPE STANDARD TABLE OF ptpsp WITH HEADER LINE,
          wrk_days type i.
    CALL FUNCTION 'HR_PERSONAL_WORK_SCHEDULE'  "get EE working days
        EXPORTING
          pernr = "EE number here
          begda = "start date in your case sy-datum
          endda = "end date in your case sy-datum+10
        TABLES
          perws = it_psp.  "now you will get work schedule within this period but more general
      "you have to take only days you are interested in
      wrk_days = 0.
      LOOP AT it_psp WHERE datum BETWEEN sy-datum AND sy-datum+10
                     AND tagty = 0      "work/paid
                     AND stdaz <> 0.   "working hours
        ADD 1 TO wrk_days.  "here you have how many days are really working ones between sy-datum and 10 days later
      ENDLOOP.

  • Get working day of month for specific date

    Hi,
    I need to get the working day of a month for a specific date. For example: Which working day is the 15th of september 2005...
    Is there any function module, I could use?
    Cheers Arne

    HI arne,
    1.  DATE_CHECK_WORKINGDAY
        This is the FM.
    2. Along with that u will have to use some logic.
    3. Just copy paste in new program
       (it will help in the logic)
    <b>It will list out
    all the working days
    between two given dates</b>
    REPORT abc.
    data : num type i.
    parameters : frdate type sy-datum default '20051216'.
    parameters : todate type sy-datum default '20051221'.
    perform getinfo using frdate todate changing num.
    break-point.
    *&      Form  getinfo
          text
    FORM getinfo USING fromdate todate CHANGING numofdays type i.
      DATA :  d TYPE sy-datum.
      d = fromdate - 1.
      DO.
        d = d + 1.
        IF d > todate.
          EXIT.
          endif.
          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.
        IF sy-subrc = 0.
          numofdays = numofdays + 1.
          write :/ d.
        ENDIF.
        ENDDO.
      ENDFORM.                    "getinfo
    regards,
    amit m.

  • FM for Holiday & Next Working day

    HI All,
    Please suggest any  single FM, which can give the current day is Holiday or not. If, Yes, the what is the next working day for a Facorty calender ID.
    Both validation should be happend in a single FM.
    Thanks & Regards,
    Prabhakar.
    Moderator message: FAQ, please search for previous discussions of this topic.
    Edited by: Thomas Zloch on Apr 18, 2011 6:13 PM

    hi ,
    Pls check this FM
    CALL FUNCTION 'BKK_CHECK_HOLIDAY'
            EXPORTING
              i_date            = wf_cntdt
              i_calendar1       = 'B1'
            IMPORTING
              e_x_no_workingday = wf_holi.
    *get actual working days upto report date.
      it_act_work_days-dat_from  = w_date-low.
      it_act_work_days-dat_to    = w_date-high.
      APPEND it_act_work_days.
    *calculate actual working days.
      CALL FUNCTION 'WFCS_FCAL_WDAYS_GET_S'
        EXPORTING
          pi_time_interval = it_act_work_days
          pi_fcalid        = 'B1'
        IMPORTING
          pe_wdays         = wf_actdays.
    regards
    Deepak.
    Edited by: Deepak Dhamat on Apr 18, 2011 12:31 PM

  • Work day of a calendar

    Hi all,
    I am searching for a FM which will say 3rd work day of a factory calendar or 4th work day of a factory calendar etc. I could see there are few FMs to say first work day - last work day but not the Nth work day. If we input some date and factory calendar, we should get which work day it is. For example if we give 09/02/2010 and factory calendar name it should return as 2nd workday etc. Any help will be appreciated..
    Thanks in advance.
    Moderator message: date calculation questions = FAQ, please search before posting.
    locked by: Thomas Zloch on Sep 15, 2010 4:39 PM

    hi,
    Please check with this fm DATE_CONVERT_TO_FACTORYDATE.
    Keerthi

  • Calculate x working days before date

    Dear experts,
    I am trying to find a date that is x working days before another.
    Is that a function module about this?
    Thank you in advance,
    Roxani

    Hi Roxani,
    You can use FM END_TIME_DETERMINE.
    There:
    - Insert in duration the number of days that you want to subtract with the minus sign (ex: -1 for previous working day)
    - Also, insert your factory calendar that you want to be the source of your working days.
    - And, of course, the desired starting date.
    Hope that helps!
    Kind regards,
    Garcia

  • Calculating Work Day Formulas

    We've recently adopted BOBJ/Webi at my company and I find the software to be rather easy to use in some instances and mind-wreckingly hard in others. One roadblock myself and other users are bumping into is calculating work days. A definition of a work day in this instance would be Monday through Friday. The monkey wrench is that we would also like to subtract out holidays, such as July 4th and Thanksgiving. Then end product would be calculating out what work day the current date is and how many days it is out of so that a simple straight-line extrapolation can be made (Metric/Current Work Day)*Total Work Days. Also, what we invoice/ship is not accounted for until the following day... for example, today (2.22.10) would be the 15th workday in February out of 20 total work days.
    Appreciate any and all help/assistance/counsel I can get on this.
    Ryan

    Hi Ryan,
    If I have understood your question then I think following solution may help you.
    Do you have your Universe created on the top of BW query or is it some other Database?
    If it is some other database then create couple of Filter at Universe level: Such as Holidays so that you can use this one to subtract holidays:
    For Example:
    ucase(Calendar_year_lookup.Holiday_Flag)
    ucase(Calendar_year_lookup.Holiday_Flag) = 'Y'
    Then you create another Dimension for Work days that would be between Monday to Friday.
    Once they are created in Universe you export Universe.
    Now create a formula where you would use month minus custom dimension workdays and minus holidays to get actual work days which would be from Monday to Friday and son on.
    Basically we can achieve this by using filters and formulas.
    Wish you good luck.
    Bashir Awan

  • Day is working day

    Hi,
    Is there any FM existing to find today is working day or holiday?
    kaki

    hi kaki,
    just check this ..i got it from SAP help.
    DATA: DATE1        LIKE SCAL-DATE,
          DATE2        LIKE SCAL-DATE,
          CORRECTION   LIKE SCAL-INDICATOR,
          CALENDAR     LIKE SCAL-FCALID,
          FACTORYDATE  LIKE SCAL-FACDATE,
          WORKDAY      LIKE SCAL-INDICATOR.
          CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
               EXPORTING  DATE                 = DATE1
                           CORRECT_OPTION       = CORRECTION
                           FACTORY_CALENDAR_ID  = CALENDAR
               IMPORTING  DATE                 = DATE2
                           FACTORYDATE          = FACTORYDATE
                           WORKINGDAY_INDICATOR = WORKDAY
               EXCEPTIONS CORRECT_OPTION_INVALID     = 1
                            DATE_AFTER_RANGE           = 2
                           DATE_BEFORE_RANGE          = 3
                           DATE_INVALID               = 4
                           FACTORY_CALENDAR_NOT_FOUND = 5.
    check the workday and analyze...
    the documentation says..
    <b>Flag whether date is a workday
    Possible values are:
    ' ' the specified date is a working day.
    '+' the specified date is not a working day,
        the following working day is returned.
    '-' the specified date is not a working day,
        the previous working day is returned.</b>

  • Last Working Day Variable

    Hello Folks,
    Any idea about the Std Variable for the last working day calculation.
    I have a customised Characteristics to which I want to use this variable then what steps should I follow or by installing it through  content will it directly get attached, I mean will be available while choosing the variables for this characteristics in a query.
    Thanks,
    Suyog.

    Hi,
    Create a customer exit variable to get last working day of the month and write the following logic in ZXRSRU01:
    *Last working day of the given period(Cal Yr/Month)
    WHEN '<Customer exit variable>'.
    DATA : BEGIN OF i_holidays OCCURS 0.
            INCLUDE STRUCTURE iscal_day.
    DATA : END OF i_holidays,
          v_fdate LIKE sy-datum,
          v_ldate LIKE sy-datum.
        IF i_step = 2.
          READ TABLE i_t_var_range INTO loc_var_range
                WITH KEY vnam = '<Cal yr/month selection variabel>'.
          IF sy-subrc = 0.
              CONCATENATE loc_var_range-low
                          '01' INTO v_fdate.
    * to get last day of the given period
              CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
                EXPORTING
                  day_in            = v_fdate
                IMPORTING
                  last_day_of_month = v_ldate.
    *To get holiday list in the given period
                CALL FUNCTION 'HOLIDAY_GET'
                  EXPORTING
                    holiday_calendar = <Fact cal ID>
                    factory_calendar = <Fact cal ID>
                    date_from        = v_fdate
                    date_to          = v_ldate
                  TABLES
                    holidays         = i_holidays.
              SORT i_holidays BY date DESCENDING.
              DELETE ADJACENT DUPLICATES FROM i_holidays.
              DO.
                READ TABLE i_holidays WITH KEY date = v_ldate.
                IF sy-subrc NE 0.
                  v_ldate = v_ldate - 1.
                ELSE.
                  l_s_range-sign = 'I'.
                  l_s_range-opt = 'EQ'.
                  l_s_range-low = v_ldate.
                  APPEND l_s_range TO e_t_range.
                  CLEAR:l_s_range.
                    EXIT.
                  ENDIF.
              ENDDO.
         ENDIF.
        ENDIF.
    Assumptions:
      Running a report by entering Cal yr/month as selection value.
    hope it works...
    regards,
    Raju

Maybe you are looking for

  • WLC cert to avoid the security warning page

    Hi guys, I am doing some tests with installiing a 3rd party cert on a WLC to avoid the security warning page when trying to access the WLC through https, and I am following the following configuration example: http://www.cisco.com/en/US/tech/tk722/tk

  • Problem with Writer.flush() appending extra character

    I have written a simple file copy that does the following:      public static void copy(File source, File dest) throws IOException           FileReader fr = new FileReader(source);           FileWriter fw = new FileWriter(dest);           try        

  • Windows 8 Activation

    while acyivating windows it shows error windows could't be activated go to control panel to learn about other ways to activate. error code : 0*8007007b error description: the filename, directory name, or volume label syntax is incorrect.

  • Business Connector Adapter

    Hello, I'm trying to send data from Business Conector to XI with the sender business conector adapter. these are the steps i did: 1. set up a routing roule in the BC 2. did the configuration for the BC-Adapter sender. 2b. configure the standard modul

  • Need help, happening for a while now.

    My iPod Touch 4g isn't responding to me. It's not jail broken or damaged. When I tried to update the iPod to the lastest one, the screen turned black and the apple logo was blinking every 10 seconds. When I try to restore it, there is a error 3194. W