How to Calculate End-Date for a given Startdate in business hours without holidays
Hello Experts,
I need to create a plsql function where we need to determine end date for a task. For this, input will be only start date & number of hours allocated for that task. Based on this input we need to exclude Business hours & need to include only Business hours. and in the end we need to achieve the end date after the hour addition to the start date.
Example : INPUT: 03-OCT-2013 12:00:00 PM /
Hours Allocated 30 Hrs.
Business Hours - 11 AM to 9 PM.
So time starts from or Startdate is Friday 03-OCT-2013 12:00:00 PM.
So If I want to calculate the end-date by adding 30 hours to it, it should come WednesDay 09-OCT-2013 12:00:00 PM because I excluded Weekends & considered only business hours that is 11 am to 9 pm.
I am not able to get any such guidance in Internet as most of the docs are having start & end date as input.
Please help!
Thanks in advance !!
Hi,
As Christ said, there's no nuilt-in Oracle function to tell whether a given DATE is a holiday or not, partially because there's so much local variation in holidays. You can write a function like that (see http://forums.oracle.com/forums/message.jspa?messageID=3351081 ), but creating a table will be simpler and more efficient.
I suggest creating a row for every date, whether it's a work day or not; that way, you can have variations in the schedule (e.g., schedule changes and
partial holidays).
CREATE TABLE work_calendar
( dt DATE PRIMARY KEY
CONSTRAINT work_calendar_dt
CHECK (dt = TRUNC (dt))
, day_type VARCHAR2 (8) NOT NULL
CONSTRAINT work_calendar_day_type
CHECK ( day_type IN ( 'HOLIDAY'
, 'WEEKEND'
, 'WORK DAY'
, start_time DATE
, end_time DATE
, work_hours NUMBER
, work_hours_since_1970 -- or some point earlier than you'll ever need
NUMBER
, CONSTRAINT work_calendar_start_time
CHECK ( TRUNC (start_time) = dt)
, CONSTRAINT work_calendar_end_time
CHECK ( TRUNC (end_time) = dt)
This will let you do a lot of the calculations you need without a function.
Similar Messages
-
How to calculate ACTUAL QUANTITY for a given PM order
hello all,
i have an ALV report requirement like below...
(for given Pm order AUFK-AUFNR)
i need to display
material no material desc requirement quantity Units of measure Actual quantity
these fields i have taken from RESB table (matnr from RESB ,maktx from MAKT, bdmng from RESB, units of measure from RESB ),
now my question is from where do i get actual quantity ....
in which table does this actual quantity will be stored....
thankq....Check with field RESB-ENMNG as mentioned by Custodio.
He meant this field only by saying
If so, it's also in RESB-DENMNG.
I guess.
This will only give you the quantity withdrawn.
But for Actual Consumption Based on date you can use AUFM ( this table gives the Material Movements carried out for Prod. Order ). -
how can i get the start date and end date for a given week
like if i give week no. 28 then it will return the dates of the week like
start date = 10-07-2006
end date = 16-07-2006.
abhishekHi,
You can use the FM <b>GET_WEEK_INFO_BASED_ON_DATE</b>
Import parameters Value
DATE 07/13/2006
Export parameters Value
WEEK 200628
MONDAY 07/10/2006
SUNDAY 07/16/2006
Regards
vijay -
Need a function to calculate employee attendance data for a given period
need a function to calculate employee attendance data for a given period
as
Working days,
CL ,
SL,
PL,
LWP
regards,
Gaurav Sood.Issue resolved
-
How to calculate first date and end date of this year in Query
Hi Expert
I want to calculate following dates with inputted date in query.
I have no knowledge on ABAP and I just can create a query with simple logic.
Could you teach me how to calculate following date?
(If inputted date is April 12 2009)
- First date of this year (Ex January 1 2009)
- End date of this year (Ex December 31 2009)
- First date of last year (Ex January 1 2008)
- End date of last year (Ex December 31 2008)
- First date of this month (Ex April 1 2009)
Thank you!
TakeHR_JP_MONTH_BEGIN_END_DATE use this FM to get the begin and end date of the Date you are passing. eg when u give input as 04/12/2009, it will return
04/01/2009 as begin date
04/30/2009 as end date
pass the Year in this FM HR_E_GET_FISC_YEAR_DATES, you will get the Fiscal year Begin and End Dates
Abh -
How to set a default start and/or end date for New Events based on trigger date.
I'm using the CalendarActivityListener to get current row when clicking on an existing event. As per previous posts this listener gives you access to event detail including Start Date, End Date, etc.
However, what I want to do is to default the start (and end) dates for New Events based on the trigger date.
I've tried the CalendarListener and can grab the Trigger Date from it - however, I can't see a way to pass this directly to the popup/dialog I'm using to create the new event.
At present I'm putting the TriggerDate into the ADFContext session scope e.g. ADFContext.getCurrent().getSessionScope().put("TriggerDate",calendarEvent.getTriggerDate());
Then, I've tried multiple approaches to try and "get" the TriggerDate from session scope to drop it into my new Calendar Event basically, I'm trying to default the InputField(s) associated with the Start Date using the value from the session - I've tried
1. setting the default value for the InputField in the jspx using a binding expression i.e. value="#{sessionScope.TriggerDate}" - this actually sets the value appropriately when the jspx is rendered but, when I go to create I get a NPE and I can't debug. I assumed that it might be a Date type issue - it would appear that CalendarListener provides a date of type java.util.Date and that the StartDate attribute of my VO/EO/table is a DATE and therefore requires oracle.jbo.domain.Date so I tried casting it - to no effect
2. Using a Groovy expression *(StartDate==null?adf.context.sessionScope.TriggerDate:StartDate)* in my calendar's EventVO to default the Start Date to the same result
Any thoughts or ideas?John,
Thanks for that suggestion - could not get it to work. However, I did manage a different approach. I finally determined the sequence of events in terms of how the various events and listeners fire (I think).
Basically, the CalendarActivityListener fires, followed by the listener associated with the Calendar object's Create facet, followed finally by the CalendarEventListener - the final is where the TriggerEvent is available and then finally, control is passed to the popup/dialog in the Create facet. So, my approach of trying to set/get the TriggerDate in the user's HTTP session was doomed to failure because it was being get before it had been set :(
Anyway, I ended up adding a bit of code to the CalendarEvent listener - it grabs the current BindingContext, navigates through the DCBindingContainer to derive an Iterator for the ViewObject which drives the calendar and then grabs the currently active row. I then do a few tests to make sure we're working with a "new" row because I don't want to alter start & end dates associated with an existing calendar entry and then I define the Start and End dates to be the Trigger Date.
Works just fine. Snippet from the listener follows
BindingContext bindingContext = BindingContext.getCurrent();+
*if ( bindingContext != null ) {*+
DCBindingContainer dcBindings = (DCBindingContainer) bindingContext.getCurrentBindingsEntry();+
DCIteratorBinding iterator = dcBindings.findIteratorBinding("EventsView1Iterator");+
Row currentRow = iterator.getCurrentRow();+
if ( currentRow.getAttribute("StartDate") == null)+
currentRow.setAttribute("StartDate", calendarEvent.getTriggerDate());+
if (currentRow.getAttribute("EndDate")==null)+
currentRow.setAttribute("EndDate", calendarEvent.getTriggerDate());+
*}* -
How to calculate Time difference for a single line item
Hi All,
I have an issue where you have to calculate the Start time and End Time , Start Date and End Date for a particular Work item number
For eg ;
WI_ID WI_CD WI_CT
000001312610 02/09/2009 09:48:4 02/09/2009 09:48:9
000001312610 02/09/2009 09:54:4 02/09/2009 09:54:9
000001312610 02/09/2009 09:54:5 02/09/2009 09:54:9
000001312610 02/09/2009 10:07:0 02/09/2009 10:07:9
000001312610 02/09/2009 10:07:0 02/09/2009 10:07:9
000001312610 02/09/2009 10:16:5 02/09/2009 10:16:9
000001312610 02/09/2009 10:16:7 02/09/2009 10:16:9
Similarly I get the Endtime and ENd dayfrom other table for same work item.So my requirement here is
in the it should show the display in a single cell .as, 5secs, 5 secs,4 secs,9secs,4 secs,2 secs
for each work item.
Can any body help me on this issue.
Any pionters for this are much helpful for me.
Thanks
Rohini.Timestamp is date and time together in one field..
Search for data element TIMESTAMP.
If you are getting this in your table.
If you are getting time and date in different fields then you can use the function module
given below....
CALL FUNCTION 'DELTA_TIME_DAY_HOUR'
EXPORTING
t1 =
t2 =
d1 =
d2 =
IMPORTING
MINUTES =
Then you can convert minutes into seconds..
Function module credit to BrightSide it works....but only it will give difference in minutes
Regards,
Lalit Mohan Gupta. -
Previous month end data for report
Hi expert,
I have to calculate previous month end data for my report.
let say if user select 15 oct then he should be able to see 30 sept data.
I have calander prompt.
Thanks,Hi,
Use presentation variable in date prompt.
Apply sql filter(covert to sql) on report as date_column= TIMESTAMPADD(SQL_TSI_DAY,-DAYOFMONTH(date 'presntation_variable'),date 'presentation_variable')
Refer : How to get LAST_DAY in obiee
Regards,
Srikanth -
How to calculate Average balance for an account
Hi,
How to calculate average balance for an account for a particular period say for JAN-12 period and after the end of that period for another two days 01-feb-12 and 01-feb-12 ?
I'm using the following query :
SELECT cc.segment1||'-'||cc.segment2||'-'||cc.segment3||'-'||cc.segment4||'-'||cc.segment5||'-'||cc.segment6 "Account_XX",
nvl(sum(l.accounted_dr - l.accounted_cr),0) "Balance"
FROM gl_code_combinations cc,
gl_je_lines l
WHERE cc.code_combination_id = l.code_combination_id
AND l.set_of_books_id ='XX'
and code_combination_id = replace it with code combination_id for account_xx
AND l.effective_date <= '31-Jan-12' (january period end ??)
GROUP BY cc.segment1||'-'||cc.segment2||'-'||cc.segment3||'-'||cc.segment4||'-'||cc.segment5||'-'||cc.segment6
There are some discrepancies in "average balance" after end of month (Jan-12)?
How to calculate average balances for a particular account (Account_XX above)from end of month of Jan to first two days of february?
Thanks,
KiranKiran,
Please let me know first, is Average Balancing feature enabled in your GL Ledger?
Regards
Muhammad Ayaz -
How to Get Missing Dates for Each Support Ticket In My Query?
Hello -
I'm really baffled as to how to get missing dates for each support ticket in my query. I did a search for this and found several CTE's however they only provide ways to find missing dates in a date table rather than missing dates for another column
in a table. Let me explain a bit further here -
I have a query which has a list of support tickets for the month of January. Each support ticket is supposed to be updated daily by a support rep, however that isn't happening so the business wants to know for each ticket which dates have NOT been
updated. So, for example, I might have support ticket 44BS which was updated on 2014-01-01, 2014-01-05, 2014-01-07. Each time the ticket is updated a new row is inserted into the table. I need a query which will return the missing dates per
each support ticket.
I should also add that I DO NOT have any sort of admin nor write permissions to the database...none at all. My team has tried and they won't give 'em. So proposing a function or storable solution will not work. I'm stuck with doing everything
in a query.
I'll try and provide some sample data as an example -
CREATE TABLE #Tickets
TicketNo VARCHAR(4)
,DateUpdated DATE
INSERT INTO #Tickets VALUES ('44BS', '2014-01-01')
INSERT INTO #Tickets VALUES ('44BS', '2014-01-05')
INSERT INTO #Tickets VALUES ('44BS', '2014-01-07')
INSERT INTO #Tickets VALUES ('32VT', '2014-01-03')
INSERT INTO #Tickets VALUES ('32VT', '2014-01-09')
INSERT INTO #Tickets VALUES ('32VT', '2014-01-11')
So for ticket 44BS, I need to return the missing dates between January 1st and January 5th, again between January 5th and January 7th. A set-based solution would be best.
I'm sure this is easier than i'm making it. However, after playing around for a couple of hours my head hurts and I need sleep. If anyone can help, you'd be a job-saver :)
Thanks!!CREATE TABLE #Tickets (
TicketNo VARCHAR(4)
,DateUpdated DATETIME
GO
INSERT INTO #Tickets
VALUES (
'44BS'
,'2014-01-01'
INSERT INTO #Tickets
VALUES (
'44BS'
,'2014-01-05'
INSERT INTO #Tickets
VALUES (
'44BS'
,'2014-01-07'
INSERT INTO #Tickets
VALUES (
'32VT'
,'2014-01-03'
INSERT INTO #Tickets
VALUES (
'32VT'
,'2014-01-09'
INSERT INTO #Tickets
VALUES (
'32VT'
,'2014-01-11'
GO
GO
SELECT *
FROM #Tickets
GO
GO
CREATE TABLE #tempDist (
NRow INT
,TicketNo VARCHAR(4)
,MinDate DATETIME
,MaxDate DATETIME
GO
CREATE TABLE #tempUnUserdDate (
TicketNo VARCHAR(4)
,MissDate DATETIME
GO
INSERT INTO #tempDist
SELECT Row_Number() OVER (
ORDER BY TicketNo
) AS NROw
,TicketNo
,Min(DateUpdated) AS MinDate
,MAx(DateUpdated) AS MaxDate
FROM #Tickets
GROUP BY TicketNo
SELECT *
FROM #tempDist
GO
-- Get the number of rows in the looping table
DECLARE @RowCount INT
SET @RowCount = (
SELECT COUNT(TicketNo)
FROM #tempDist
-- Declare an iterator
DECLARE @I INT
-- Initialize the iterator
SET @I = 1
-- Loop through the rows of a table @myTable
WHILE (@I <= @RowCount)
BEGIN
-- Declare variables to hold the data which we get after looping each record
DECLARE @MyDate DATETIME
DECLARE @TicketNo VARCHAR(50)
,@MinDate DATETIME
,@MaxDate DATETIME
-- Get the data from table and set to variables
SELECT @TicketNo = TicketNo
,@MinDate = MinDate
,@MaxDate = MaxDate
FROM #tempDist
WHERE NRow = @I
SET @MyDate = @MinDate
WHILE @MaxDate > @MyDate
BEGIN
IF NOT EXISTS (
SELECT *
FROM #Tickets
WHERE TicketNo = @TicketNo
AND DateUpdated = @MyDate
BEGIN
INSERT INTO #tempUnUserdDate
VALUES (
@TicketNo
,@MyDate
END
SET @MyDate = dateadd(d, 1, @MyDate)
END
SET @I = @I + 1
END
GO
SELECT *
FROM #tempUnUserdDate
GO
GO
DROP TABLE #tickets
GO
DROP TABLE #tempDist
GO
DROP TABLE #tempUnUserdDate
Thanks,
Shridhar J Joshi
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'> -
How to get the date for the last day of a week?
Is there a easy way to get the date for the last day of week?
eg a week starts on monday and end on sunday
January 11, 2005 is the start date for the week
January 17, 2005 is the end date for the week
or
say
February 26, 2003 is the start date for the week
March 5, 2003 is the end date for the week
I just need a simple way of figuring that out....
I figured out how to get the start date for the week but just can't get the latter..
formatting of the date is not of a concern.. that I know how to do
thanks in advanceHow about something like the following?
Calendar someDay = new GregorianCalendar(2005,0,11);//2005 Jan, 11
//Note above that January is 0, not 1, as counting starts from 0.
someDay.add(Calendar.DAY_OF_MONTH,6); //add 6 days
java.util.Date lastDayOfWeek = someDay.getTime();
//If someDay was the start of a week, lastDayOfWeek should now be
//the last day of that week.
System.out.println(lastDayOfWeek.toString() ); -
Quarter End date for this period
Hi
I have current date, How could I get the quarter end date for this date.
for example
Jan 23 2005 - The quarter end date is Mar 31 2005.needs testing
import java.util.Calendar;
import java.text.SimpleDateFormat;
class Testing
public Testing()
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH,3-(cal.get(Calendar.MONTH)%3));
cal.set(Calendar.DAY_OF_MONTH,0);
System.out.println(sdf.format(cal.getTime()));
cal.set(2005,10,15);
cal.add(Calendar.MONTH,3-(cal.get(Calendar.MONTH)%3));
cal.set(Calendar.DAY_OF_MONTH,0);
System.out.println(sdf.format(cal.getTime()));
public static void main(String[] args){new Testing();}
} -
Revision: 10545
Author: [email protected]
Date: 2009-09-23 13:33:21 -0700 (Wed, 23 Sep 2009)
Log Message:
Make DataGrid smarter about when and how to calculate the modulefactory for its renderers when using embedded fonts
QE Notes: 2 Mustella tests fail:
components/DataGrid/DataGrid_HaloSkin/Properties/datagrid_properties_columns_halo datagrid_properties_columns_increase0to1_halo
components/DataGrid/DataGrid_SparkSkin/Properties/datagrid_properties_columns datagrid_properties_columns_increase0to1
These fixes get us to measure the embedded fonts correctly when going from 0 columns to a set of columns so rowHeight will be different (and better) in those scenarios
Doc Notes: None
Bugs: SDK-15241
Reviewer: Darrell
API Change: No
Is noteworthy for integration: No
tests: checkintests mustella/browser/DataGrid
Ticket Links:
http://bugs.adobe.com/jira/browse/SDK-15241
Modified Paths:
flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/DataGrid.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/dataGridClasses/DataGridBase .as
flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/dataGridClasses/DataGridColu mn.asHi Matthias,
Sorry, if this reply seems like a products plug (which it is), but this is really how we solve this software engineering challenge at JKI...
At JKI, we create VI Packages (which are basically installers for LabVIEW instrument drivers and toolkits) of our reusable code (using the package building capabilities of VIPM Professional). We keep a VI Package Configuration file (that includes a copy of the actual packages) in each of our project folders (and check it into source code control just as we do for all our project files). We also use VIPM Enterprise to distribute new VI Packages over the network.
Also, as others have mentioned, we use the JKI TortoiseSVN Tool to make it easy to use TortoiseSVN directly from LabVIEW.
Please feel free to contact JKI if you have any specific questions about these products.
Thanks,
-Jim -
How to calculate acquisition value for specified day
Hi,
in my z program I have a problem how to calculate acquisition value for my asset for specified day.
Example:
I have asset created 8.7.2008 with TTYPE 104 (External asset acquisition) with value 5950.
30.11.2008 there is another TTYPE 272 (Retirement of current-yr acquis., w/o revenue) with value 950.
So BEFORE 30.11.2008 acquisition value is 5950. After is 5000. Is there any function module (or something else) in SAP system where I can send asset number and date a it return to me acquisition value for that day?
Many thanks for any answer!Hi,
your suggestion means that I have to compute acquisition value by myself (sum all TTYPE 1** - sum all TTYPE 2**). So SAP does't provide such functionality (LDB ADA have it, because it can compute acquisitiob value for specific day)?
Mant thanks for answer -
How system calculate Exchange Rate for material?
I have some doubt how system calculate exchange rate for material when doing GR.
For example, standard price of material is 0.01 USD per ea. PO is created in foreign currency (THB) with qty: 40,000 ea (THB 2,852.00)
Actually when I do GR ea then accounting doc is:
Dr. Inventory 400 USD (12,800 THB)
Cr. GR/IR 88.64- USD (2,852.00- THB)
Cr. Variant 311.36- USD (9,948.00- THB)
for 2nd and 3rd line item, exchange rate M (THB -> USD) is 0.03108 which is correct.
Could anyone advise where system get exchange rate for 1st line item?Hi
First of all, as mentioned by you, the exchange rate for Item 2 and 3 is not 0.03108.. It is as below, based on the figures given by you...
Dr. Inventory 400 USD (12,800 THB)........ Exch rate is 0.03125
Cr. GR/IR 88.64- USD (2,852.00- THB)....... Exch rate is 0.03108
Cr. Variant 311.36- USD (9,948.00- THB).... Exch rate is 0.0313
I guess the item 3 is just a derivation from Items 1 and 2.. The Price diff results as a difference between std cost and purchase price...
I believe, the exchange rate would have been 0.03125 at the time of GR... You need to check this in your system... For sure, it uses exch rate type M in the standard... Check if 0.03125 (USD -> THB) or 32 THB -> USD exists in your system at all
Item 2 is based on your PO negotiated rate...
Regards
Ajay M
Maybe you are looking for
-
Triggered mail on record changes in infotype 9(bank details)
Hi All, We have a requirement for triggering a mail notification on any record changes in table pa0009 (Bank Details - infotype 9). Please suggest. Thanks & Regards, Sujatha sahu.
-
Hello, I want to get into SAP BI and have some questions about it. Is there a big downside in installing only the BI components without the Java BI components, or is it even possible if you want to work with BI. What are the general differences betwe
-
hi friends, is there any table for sales order stock in sap. with regards Bhupi
-
Aperture 2.0 is now available.
Happy now?
-
Transfere from Oracle to Access
HI I have took an exported file for one table and I want to import it in Access database. Is there any way to do that,If yes ,How can I do that? bye