Next Non Holiday date

I need to find the next non holiday date for a set of rows in table.I have a separate table where all holidays are listed.Please help me to find the next non holiday date using decode function.
Holiday Table sructure:
create table holiday(no number,holidaydate date);
insert into holiday values(1,to_date('17-AUG-2013','dd/mm/yyyy');
insert into holiday values(1,to_date('05-SEP-2013','dd/mm/yyyy');
I have a code which seems to be wrong.
select decode (lapsedate ,
                                           laps.holidaydate , DECODE
                                                 (lapsedate +1,
                                                  laps.holidaydate + 1, DECODE
                                                          (lapsedate + 2,
                                                             laps.holidaydate
                                                           + 2, lapsedate
                                                            + 3,
                                                           lapsedate + 2
                                                  lapsedate + 1
                                           lapsedate
                                          ) from dt;

Hi,
Here's one way to do that with your current tables:
WITH    cntr       AS
    SELECT  LEVEL   AS n
    FROM    dual
    CONNECT BY   LEVEL <= 4 -- longest possible distance to next work day
SELECT    m.ndate
,         m.ndate + MIN (c.n)   AS next_work_day
FROM             mycalendar  m
CROSS JOIN       cntr        c
LEFT OUTER JOIN  holiday     h   ON  h.holidaydate = m.ndate + c.n
WHERE     h.holidaydate  IS NULL
AND       TO_CHAR ( m.ndate + c.n
                  , 'Dy'
                  , 'NLS_DATE_LANGUAGE=ENGLISH'  -- If needed (but never hurts)
                  )    NOT IN ('Sat', 'Sun')
GROUP BY  m.ndate
ORDER BY  m.ndate
This assumes that the next work day (that is, non-holiday, Monday through Friday) will be within the next 4 days (which is true where I work).  You may need to change the magic number in cntr (4, above) depending on your holidays.
Instead of a holiday table with 1 row per holiday, consider having a calendar table, with 1 row per day, regardless of whether the day is a holiday, weekend or work day.  You can have a next_work_day column in the table (populated by a query similar to the one above).  It will be more efficient in the long run, and will make coding individual queries much simpler.

Similar Messages

  • Retrieving spatial and non spatial data in one query

    Hello. I am having slight difficulties using JDBC to retrieve both spatial and non spatial data in the same query. The following is code from a sample program of mine that retrives spatial data from spatial tables.
    (In spatialquery geom is a geometry column and city is simply the name of the city):
    try
    Geometry geom = null;
    String database = "jdbc:oracle:thin:@" + m_host + ":" + m_port + ":" + m_sid;
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = (OracleConnection)DriverManager.getConnection(database, sUsername, sPassword);
    GeometryAdapter sdoAdapter =
    OraSpatialManager.getGeometryAdapter("SDO", "8.1.7", STRUCT.class, null, null, con);
    String spatialquery = "SELECT a1.geom, a1.city \n" +
    "FROM cities a1";
    Statement stmt = con.createStatement();
    OracleResultSet rs = (OracleResultSet) stmt.executeQuery(spatialquery);
    int i = 0;
    int noOfFeatures = 2;
    while (rs.next())
    for(i = 1; i <= noOfFeatures; i++)
    STRUCT dbObject = (STRUCT)rs.getObject(i);
    try
    geom = sdoAdapter.importGeometry(dbObject);
    catch(GeometryInputTypeNotSupportedException e)
    System.out.println("Input Type not supported");
    catch(InvalidGeometryException e)
    System.out.println("Invalid geometry");
    System.out.println(geom);
    }//end while loop
    This retrieves the sptial data fine, however when I attempt to retreive the non-spatial data I keep getting a "ClassCastException" error. I understand it is something to do with "STRUCT dbObject = (STRUCT)rs.getObject(i);" line. Can anyone tell me how to retrieve both spatial and non-spatial data in the one query using JDBC. I have tried nearly everything at this stage. Cheers joe

    Theresa A Radke
    Posts: 20
    OTN Member Since: Jul, 2001
    retrieving spatial and non spatial in same query. May 23, 2003 12:02 AM
    retrieving spatial and non spatial in same query.

  • Error in Get Next Non-Text Sibling for XML without CR at end of tag

    Hallo all,
    I'm having a strange error parsing XML files with labview. I have an XML file in one single line, without CR at end of each tag. A normal browser or XML parsing tool is capable to read it, but not with Labview.
    The error I have is with "Get Next Non-Text Sibling.vi", which internally fails to read Type property (Error -2630, Property Node (arg 1) in NI_XML.lvlib:Get Next Non-Text Sibling.vi->XML Get Siblings Childs Nodes.vi->Encode data to label (Path).vi).
    Labview XML parser works if I add a CR at each tag/node.
    I'm quite sure this is a labview bug. A workaround I have found is to open the file, then save the file with Save File (Pretty Print) method and reopen it again, but it is time-consuming and I would like to avoid it.
    Regards,
    Daniele
    Solved!
    Go to Solution.
    Attachments:
    xmlwithnoCR.xml.txt ‏1 KB

    Which node do you pass to XML Get Siblings Child Nodes.vi ? That is also important.
    I can imagine the following scenario causing your problem: Your input node has a child node C,, but this child node has no siblings. Get Next Non-Text Sibling.vi will fail in this case. If you put a <CR> at the right position in your XML you create a text node with content <CR>. If this text node is a sibling of child C then Get Next Non-Text Sibling.vi still won't return anything but no error should occur. IMHO this is expected behavior. You can however implement your own version of Get Next Non-Text Sibling.vi. Use the Next Sibling property and check if it returns a valid refnum.

  • Next Years Meeting Dates

    Been toying with different thoughts, SQL and Functions but haven't come up with the right plan of action.
    We have a monthly meeting, typically on the 1st Monday of the Month. Occasionally it needs to be different. The date needs to be saved to a Table for referencing other code and documents on the server. These are some of the things I have toyed with in trying
    to figure out how to do it.
    I have a Form that uses =DMax("BoardDates","Board and submission dates") to return the highest date in the Table.
    There are several functions in a Standard Module from the Forums
    1)
    '"the following function was made to display info on Report"
    Public Function fnIsFirstMondayOfMonth(dteInput As Date) As Boolean
    fnIsFirstMondayOfMonth = (Day(dteInput) <= 7) _
    And (Weekday(dteInput) = vbMonday)
    End Function
    2)
    'The following function by Dirk is to try creating dates on a Form to store in the Tables
    Function fncFirstMondayOfNextMonth( _
    BaseDate As Date, _
    Optional WeekdayWanted As VbDayOfWeek = vbMonday) _
    As Date
    ' Given a datem return the date of the first occurrence
    'of a given day of the week in the next month.
    ' The default is the first Monday
    ' but the optional WeedayWanted argument
    ' can be used to specify any desired day of the week, as
    ' a member of the vbDayOfWeek enum.
    Dim dtNextYear As Date
    Dim dtNextMonth As Date
    Dim intDay As Integer
    ' Start with the first day of next month.
    dtNextMonth = DateSerial(Year(BaseDate), Month(BaseDate) + 1, 1)
    ' Find the first <WeekdayWanted> on or after dtNextMonth.
    intDay = Weekday(dtNextMonth)
    'fncFirstWeekdayOfNextMonth = DateAdd("d", (WeekdayWanted + IIf(intDay > WeekdayWanted, 7, 0)) - intDay, dtNextMonth)
    End Function
    3)
    'The following function by Ken is to try creating future dates on a Form to store in the Table
    Public Function GetMondayDate(dtmDate As Date, intWeekNum As Integer)
    On Error GoTo Err_Handler
    Const NOCURRENTRECORD = 3021
    Dim rst As DAO.Recordset
    Dim strSQL As String
    Dim strFrom As String
    Dim strTo As String
    Dim n As Integer
    Dim dtmReturnDate As Date
    ' get start and end dates of next month as date literals
    ' in internationally unambiguous ISO format of YYYY-MM-DD
    strFrom = "#" & Format(DateSerial(Year(dtmDate), _
    Month(dtmDate) + 1, 1), "yyyy-mm-dd") & "#"
    strTo = "#" & Format(DateSerial(Year(dtmDate), _
    Month(dtmDate) + 2, 0), "yyyy-mm-dd") & "#"
    ' establish a recordset of all Wednesday dates in next month
    strSQL = _
    "SELECT WeekStart " & _
    "FROM WednesdayCalendar " & _
    "WHERE WeekStart BETWEEN " & _
    strFrom & " AND " & strTo & _
    " ORDER BY WeekStart"
    Set rst = CurrentDb.OpenRecordset(strSQL)
    ' loop until required week of month
    ' and get Wednesday date
    With rst
    Do While n < intWeekNum
    dtmReturnDate = .Fields("WeekStart")
    n = n + 1
    .MoveNext
    Loop
    End With
    GetMondayDate = dtmReturnDate
    Exit_Here:
    Exit Function
    Err_Handler:
    ' if number of weeks in month with a Wednesday
    ' has been exceeded return a Null
    ' otherwise inform user of any unknown error
    Select Case Err.Number
    Case NOCURRENTRECORD
    GetMondayDate = Null
    Case Else
    MsgBox Err.Description, vbExclamation, "Error"
    End Select
    Resume Exit_Here
    End Function
    Then have tried the following in unbound controls on the Form with a highest date in the Table at 11/3/2015.
    =IIf(fnIsFirstMondayOfMonth([HighestDate]+DatePart("m",2)),Null,"*") & Format([HighestDate],"mmmm dd"", ""yyyy") which returns - The current Date preceded by *
    =IIf(("m",[highestdate]>10),DateAdd("m",1,[HighestDate]),[highestdate]) Returns The current date + 1 Month (12/3/2015)
    =DateDiff("d",Now(),[HighestDate]) - Returns the difference between today's date and the highest date in the Table (315)
    =Format(DateDiff("d",Now(),[HighestDate]),"yyyy") - Returns 1900
    =Format([HIghestDate],"yyyy")+1 - Returns the Next highest Year (2016)
    =DateAdd("d",("Monday"+IIf([intDay]>[WeekdayWanted],7,0))-[intDay],[dtNextMonth]) - Returns #Name? error
    =DateAdd("d",(3+IIf(Day(DateSerial(Year(Date()),Month(Date())+1,1))>3,7,0))-Day(DateSerial(Year(Date()),Month(Date())+1,1)),DateSerial(Year(Date()),Month(Date())+1,1)) - Returns 1/3/2015
    =DateAdd("d",7-(7-Day(DateAdd("m",1,DateSerial(Year(Date()),Month(Date()),0)+1))),DateAdd("m",1,DateSerial(Year(Date()),Month(Date()),0)+1)) - Returns 1/2/2015
    =DateDiff("y",[HighestDate],DateAdd("y",+1,DateAdd("yyyy",3,[HighestDate]))) - Returns 1097
    =(365-Day(Now())) - Returns 342
    =DateAdd("y",-1,(Now())) - Returns 12/22/2014 2:41:03 PM
    =IIf([HighestDate]<Now(),Now(),DateAdd("d",+1,Now())) - Returns 12/24/2014 2:41:03 PM
    =Format(IIf([HighestDate]<Now(),Now(),DateAdd("yyyy",+1,Now())),"yyyy") - Returns the year of the highest date (2015)
    So we need to be able to have on the Form the 11 dates in Bound controls based on the selected year in an unbound Form, and then have 11 unbound controls show the next years monthly meeting dates. A button to update the unbound dates to the Table provided
    those months of the year do not already have dates. We don't want the code to update the Table if the Month/Year already has a date as 1 or 2 times a year the dates will be deferred and we need the deferred date to remain.
    I was also looking at using the following code to make it work???
        If Len(Trim(Nz(Me.[JanMDate], "") & "")) = 0 Then
        'check to see if the text box already has data - if it doesn't then
        Me.[JanMDate] = DateAdd("d", 365, Me.[HighestDate])
        'use the Highest date value and calculate next years dates to store in the unboun date text boxes
        End If
    Thank you for your help!!!
    Just takes a click to give thanks for a helpful post or answer.
    Please vote “Helpful” or Mark as “Answer” as appropriate.
    Chris Ward
    Microsoft Community Contributor 2012

    If not automated, regular compacting of a database should be a maintenance task undertaken by the database administrator, but failing that I can see three possible approaches:
    1.  Create the temporary table in an external file, which is itself created and deleted at runtime.  The BoM demo in my OneDrive folder adopts this approach to create temporary tables on the fly to simulate recursive querying to generate a bill of
    materials.
    2.  Adapt my code so that instead of creating a separate table from which to append rows it inserts rows into your operational table annually.
    3.  Instead of creating a temporary table, create a permanent auxiliary calendar table stretching 10 or 20 years into the future, and restrict an append query by a date range to insert a subset of rows into the operational table annually.  Auxiliary
    calendar tables are normally permanent objects as the dates in them are not usually subject to amendment, apart from the deletion of public and concessionary holidays dates as and when these become known.  In your case, however, if you created a table
    of first Mondays of each month say, the table would need to be updated if subsequently the regular dates were to change to another day in the month, e.g. 2nd Tuesday.  This would not be difficult to incorporate into the interface as it would involve no
    more than deleting rows after the first Monday dates ceased to be appropriate, and inserting rows from that date onwards for the 2nd Tuesdays.
    Ken Sheridan, Stafford, England

  • How to insert multiple data to non database data block?

    Hi all,
    I'm new in using form builder. I have a question about insert multiple data to non database data block.
    I want to upload a csv file that content the attendance transaction of all of employees. If the employee in that
    file doesn't exist in that company,so I must record the employee number into non database data block.
    If I just upload one employee data, I can record it to that data block. But, if more than one, it didn't works.
    May you help me?
    Thanks..
    Tika

    you might need a NEXT_RECORD or CREATE_RECORD to go to the next reord in that block. It would be easier to help if we knew your code.

  • Creating a Crystal Report from a non-SAP data base

    I have the following scenario
    server1\myDataBase
    server1\SAP\sapDataBases
    in sapDataBases I have about 30 company databases. I am trying to create a report, that gets informatino from a table/view/SP from server1\myDataBase, when I try to PREVIEW or SAVE such report on SAP Business One, I always get errors as
    I understand that this eerror means taht I can't invoke the data from out of SAP; it needs to be inside SAP (at least the SP, incoking some other data bases and stuff..)
    Some bodies have told me that it is beacuase I can only create a report from a table/view/sp that resides in the running/currently SAP company database. Is this right?
    Also, If this is the case, this means that If I have an SP taht I use for a crystal report, and 30 companies, I have to create such SP in the 30 companies?
    This is my software details:
    SQL Server 2012
    SAP Business One 9 PL 11
    SAP BusinessObjects Crystal Reports 2013 Support Pack 2 version 14.1.2.1121
    What I want to do is to create a non-SAP data base to create all the SPs/Views for reports, to centralize it, and the just create one reporte and do the 30-imports in each company database, without the need of creating such sps/views in each company-database. Is this possible?
    Thanks

    Moved to Integration Kit forum.
    The people in this forum will know more about the data structure than the CR Design forum which typically doesn't know much about the SAP Data sources Structure.
    Don

  • Next JIT schedule date in  Schedule Agreement

    H, This is reg JIT - in Schedule Agreements
    JIT schedules are created to day 10.02.2010 ..
    In Creation profile for JIT, 'Changed or next date' is given & 'Weekly trans' option is chosen
    I could see system calculated 'Next JIT sched' date as 15.02.2010 [Next week monday] , it is as expected
    I created JIT today and i am not able to release today itself as part of testing solution. Even in production environment cant i release on same day of JIT schedules creation? why so ?
    Help Says  only those scheduling agreement items with respect to which the creation date is earlier than the current date are chosen for release generation."

    I found the issue ...
    output message for JIT was an issue
    when i see JIT out message type properties for this message, Print parameters field was set to blanck
    When i chenged to Purchase Group, it worked ..
    Can some one help me what effect it had in generating message, before that message was green but i was not able to genertae JIT schedules

  • How to create a sales order having incomplete non-sap data as input start

    We have facing the following problem in our company. We have a non-SAP system where we pull data from. We built a webservice that enables a user to pull data from the non-sap sustem by entering a key value (e.g. project number). Pulling the non-sap data is not a problem. However, once the user have pulled the data via the webservice, this data (e.g. material number, qty and sales unit) needs to be transfered to the va01 screen directly. The user will have to complete the missing master data like sold to party, ship to party, customer PO number etc. Then by hitting enter standard SAP will run and if everything is OK, the user has to save the order and a sales order number will be created. We know there a lot of techniques that can be used like Idoc, BAPI, XML, RFC. We have XI, Adobe and Portal available. Does somebody have an idea for a solid solution to get this to work?
    kind regards
    Angelique Heutinck

    You want to Create Sales Order thru VA01 after puling the data from NonSAP system. Moreover you want that the Incomplete Sales Order will be saved.
    if thats the requirement - I ll suggest
    While doing VA01 - start from Create with reference Sales order. in that case default Sales Orders will be automatically created and using the BDC you can change the items  or Customers you want to change. Once the Order number is created properly  - u r free to change eveything of that Order.
    Otherwise calling BAPI / RFC for creating the sales orders is the most safest way of achieving it. But again if you dont have the complete data - calling RFC  or BAPI does not make much sense. because they will fail to create the Sales Order in case u dont fill up the mandatory fields.

  • What are the Non SAP data sources supported for Analysis workbooks?

    AO 1.4 SP6
    BO 4.1 SP2
    What are the Non SAP data sources supported for Analysis workbooks?
    Thanks.

    HANA is a data source (which could contain non-SAP data)
    For other Excel front-ends that may connect to "non-SAP" data look at Live Office or Power BI by Microsoft - see Excel and Power BI connectivity to SAP BusinessObjects Universes | Power BI

  • Working with NON-Structured Data

    Dear Colleague,
    I am preparing to build a Forms application (using Oracle 9i Developer Suite, Release 2, version 9.0.2.0.1).
    The application (and Data model) will need to associate SOPs (standard operating procedures) with certain measurements and treatments. It is planned to have the SOPs be, for example, MS Word documents, i.e. the SOPs will be non-structured data.
    What is best practice when handling this situation? Please advise.
    Assume I would like to view, print and (maybe) update the SOPs (Word files).
    1. Should I just store a link to the Word file and a corresponding description or is it better to store the Word file in the DB?
    2. If in the DB, which data type?
    3. If SOP not in the DB, but a file, what is the mechanism for retrieval and display?
    4. Printing the Word file via Forms - how? problems to avoid?
    5. Update of the Word document via Forms - possible? How?
    Best regards,
    Randy

    Hi Vijay,
    sorry
    please rewrite the formula for the button disable as::
    NOTE:: in the formula i have used '<''>'  which nothing but a lessthan symbol and greater than symbol without single quotes (i.e. not equal to)
    BOOL(IF(LEN(@Emp_code) '<''>'0 AND LEN(@Earea)'<''>'0 AND LEN(@Edept)'<''>'0 AND DSUB(DVAL(@Joining_date), DVAL(@Ending_date),'D')<0 ,false,true))
    and make sure you have placed the date picker UI controls for your date functionality.
    this will not work for calender UI control on the form.
    and othe important point is the joining date should be less than ending date then only the button will be enable..
    if you want your joining date should be greater than ending date then write the formaula like this::
    BOOL(IF(LEN(@Emp_code)<>0 AND LEN(@Earea)'<''>'0 AND LEN(@Edept)'<''>'0 AND DSUB(DVAL(@Joining_date), DVAL(@Ending_date),'D')>0 ,false,true))
    i tried this
    its working for me
    Regards
    Srinivas

  • Can't able to print Non English data properly in PDF Output

    Can't able to print non english data properly
    Example:
    I want to print the germen data (Währung),But it printing like this (Währung) in PDF out put
    What the changes i have to do to achive this
    Thanks&regards
    yamini

    Hi Yamini,
    I think this happens when you look at utf-8 in Windows wiith another character set. I've noticed that the XML file (and hence the PDF output) displays those characters when I preview reports on the BI desktop, but the output from the server is fine, so I don't worry about it.
    Tore.

  • Holiday dates app in the apps store

    Hi all.
    About 4/5 weeks ago I stumbled across an app that downloads all the holiday dates for 2009
    (saints days, bank holidays, easter etc.......)
    I think it was called 'Holiday Calendar' but I now cannot find it as I wast to purchase it.
    From what I can remember, after you download it it puts the dates into your calender so it doesnt have to be treated as a separate program.
    Can anybody help please??
    Thanks awfully old chap...
    Message was edited by: Dive junkie

    Don't know about an app, but you can go here http://icalshare.com/article.php?story=20020930183844804 and subscribe to the UK Holiday calendar in iCal on your Mac. It puts all the holidays in your calendar and you just have to incluce that calendar to sync.

  • Is it possible to upload non-numeric data into Planning from ODI?

    Dear All,
    I have problem to upload non-numeric data into planning?
    Regards,
    Thomas

    I am not sure what that has to do with non-numeric data and planning.
    If you want to move your ODI environment then have a look at this post :- Re: move full ODI environment to another Machine...
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • How do I import non-numeric data into DIAdem?

    I have some non-numeric data in an Excel file which I would like to import into DIAdem. DIAdem recognizes the file and imports some of the data, but it only imports those cells that are purely numeric. Cells containing non-numeric characters are ignored. But I need that non-numeric data! How do I force DIAdem to import everything? (Some controls appear in the import dialog that seem like they might be useful here but they're greyed out.)

    Hi There,
    You can not load text columns from ASCII files into DIAdem 8.1 DATA channels (numbers only). But the ASCII Import Wizard will let you send those text values to either a separate ASCII file, which DIAdem can use to put them on a graph as labels, or to a DIAdem string array, which DIAdem can use to display them at various places in its environment.
    The below attachments demonstrate reading an ASCII text column into a DIAdem string array and displaying the values on a DIAdem table in GRAPH. Note that the index values of the string array are placed in a DIAdem DATA channel.
    Ask if you have further questions,
    Brad Turpin
    NI
    Attachments:
    ASCII_Text_Column.txt ‏1 KB
    ASCII_Text_Column.STP ‏1 KB
    ASCII_Text_Column.LPD ‏3 KB

  • Importing non-unicode data into unicode 10gR2 database

    Hi:
    I will have to import non-unicode data into unicode 10gR2 database. The systems the data is coming from are the following: CODA, Timberline, COMMS, CMS, LIMS. These are all RDBMS, sql-enabled systems. We are talking about pretty big amounts of data (a couple hundred GB combined).
    Did anybody go through a similar exersize?
    I know I'll have to setup nls_length_semantics to CHAR.
    What other recommendations could you guys give?
    TIA,
    Greg

    I think "nls_length_semantics" isn't mandatory at this point, and you must extract a little quantity of information from every source and do some probes injecting them into the Oracle10g database.

Maybe you are looking for

  • Disk Utility shows Disk1, not mounted, and no further information???

    Disk Utility shows my correct disk partitions in the top section (my hard disk with two partitions and my superdrive). In the lower section, however, there is a "disk1" which shows no information. Under that is another "disk1" which shows only 'Not m

  • SAP R/3 4.7 INSTALLATION ON WIN-2000 ADVANCED SERVER.

    Hello! IS THERE ANYONE WHO CAN HELP ME????????? Dear, plz. Give me the steps for sap r/3 installation on win 2000 advanced server. I am not having password for sap community market place. So, iam not able to get the steps for installation I AM HAVING

  • Problem with special characters (&) when printing using XSL-FO ...

    Hello everybody !! I have a problem when I want to print a Report with a link to a URL where the character "&" is present : I want to have something like : src="file:///...webfile?param1=val1*+_&_+*param2=val2" In my XSL-FO file, I wrote : src="file:

  • Bapi for  org structure in crm

    Hi Experts ! Pls tell me the BAPI for the ORGANIZATIONAL structure in CRM. Thanks in advance. Regds Navneet

  • Need information on SAP Webshop

    Dear All, Can you please help me to find out if we can use the webshop without implementing SAP CRM. Our customer is having SAP R/3 with modules like: SD, MM, CS. It will be helpful if you can share details like: 1) What webshop is exactly used for 2