Query to get holidays including saturday and sunday by giving month and year as input
query to get holidays including saturday and sunday by giving month and year as input.
Hi,
Create a table for holidays. You could INSERT one row for each holiday in each year, but it might be more useful if you just create 1 row for every day, with a column that tells whether that day is a holday, part of a weekend, or a work day.
See
http://forums.oracle.com/forums/message.jspa?messageID=3351081
for a user-defined function that tests if a given DATE is holiday.
You could use such a function when populating the table I mentioned earlier.
Similar Messages
-
Query to get number of invoice created by user between from and to date
Dear All
I need Query to get number of invoice created by user on day and his orgainization between from and to date.
thanksselect count(*) from ap_invoices_all where created_by = :p_User_id
and trunc(creation_date) between :p_from_date and :P_to_date;
Thanks/SRK -
Query to get batch GLBATCH name for the invoices of AP and AR
Please provide a query to get GLBatch name for an invoice of AR and AR.
From one cursor iam getting invoice number and invoiceID of AP and AR.
I have written query but it is taking much time
select distinct gjb.NAME
from gl_je_headers gjh,
gl_je_lines gjl,
gl_je_batches gjb
where gjl.REFERENCE_2=to_char(:p_invoiceid)
and gjh.JE_HEADER_ID=gjl.JE_HEADER_ID
and gjh.JE_BATCH_ID=gjb.JE_BATCH_ID
so iam getting performance problem.
Please suggest if iam wrong.
Waiting for your valuable suggestion.
Thanks
ganeshHi,
the version of Oracle E-Business Suite is R12
and ORacle Database IS 11I
Thanks & Regards
ganesh -
Table for Material Quantity and Value for particular month and year
Hi All
My requirement is that for a particular month and year I want to know the stock quantity and stock value for a particular material for a given plant.From which SAP table can I get this data as I want to fetch data for my Y report?
Regards
Satish KumarHi,
You can use MB5B table as suggested earlier.also you can use:
MBEW-VMKUM --> stock for previous month period
MBEW-VJKUM --> stock for previous year period
PLease view these links which migh tbe helpful to you:
http://help.sap.com/saphelp_47x200/helpdata/en/39/55fee3bc6111d4b3960050dadf0791/content.htm
TableStock
Thanks
Nisha -
How to calc the begining and end of every month (leap year)
Hi all,
I'm looking for a method that returns the begining and end of next month.
example:
today is 2005-10-04
so the method suppose to return:
2005-11-01
2005-11-31 //as it ends on the 31
I came up with the code below - but I don't like it as I can't get the end of month + it's not safe.
any suggestions.
Thanks
Peter
Calendar gcToday = Calendar.getInstance();
int month = gcToday.get(Calendar.MONTH);
int year = gcToday.get(Calendar.YEAR);
month+=2;
if(month>12) //beacuase of month+=2;
year++;
month=1;
String nextMonth;
if (month<10)
nextMonth=year+"-0"+month+"-01";
else
nextMonth=year+"-"+month+"-01";Look at using the methods getActualMaximum() and getActualMinimum() in the Calendar class. Basically what I would do is set the calendar to the 15th of the month (well, really anything between 1 and 28) and then add() one to the current month. The Calendar will roll over the dates as needed.
-
Query to get a value for each day in a month
Hi All,
I'm needing a query (preferably without a loop or function) that can get a number representing each day of a given month.
For example for the month of February, the result would be 1,2,3,....28
Surely this can be done?
Thanks!SQL> with a as (
2 select trunc(sysdate,'Month') mon from dual)
3 SELECT mon + LEVEL - 1 AS dates
4 FROM a
5 CONNECT BY LEVEL <= ADD_MONTHS (mon, 1) - mon;
DATES
01-FEB-11
02-FEB-11
03-FEB-11
04-FEB-11
05-FEB-11
06-FEB-11
07-FEB-11
08-FEB-11
09-FEB-11
10-FEB-11
11-FEB-11
DATES
12-FEB-11
13-FEB-11
14-FEB-11
15-FEB-11
16-FEB-11
17-FEB-11
18-FEB-11
19-FEB-11
20-FEB-11
21-FEB-11
22-FEB-11
DATES
23-FEB-11
24-FEB-11
25-FEB-11
26-FEB-11
27-FEB-11
28-FEB-11
28 rows selected.or if u want it in one query,Then
SQL> SELECT trunc(sysdate,'Month') + LEVEL - 1 AS dates
2 FROM dual
3 CONNECT BY LEVEL <= ADD_MONTHS (trunc(sysdate,'Month'), 1) - trunc(sysdate,'Month');
DATES
01-FEB-11
02-FEB-11
03-FEB-11
04-FEB-11
05-FEB-11
06-FEB-11
07-FEB-11
08-FEB-11
09-FEB-11
10-FEB-11
11-FEB-11
DATES
12-FEB-11
13-FEB-11
14-FEB-11
15-FEB-11
16-FEB-11
17-FEB-11
18-FEB-11
19-FEB-11
20-FEB-11
21-FEB-11
22-FEB-11
DATES
23-FEB-11
24-FEB-11
25-FEB-11
26-FEB-11
27-FEB-11
28-FEB-11
28 rows selected.
SQL> Regards
Umesh -
Pay and go to pay monthly and keep your number all on o2, easy,
Had my NEW pay monthly sim, done a number swap on the web, then hung on 24 hours, nothing, web chat to O2, and there answer was, I was swaping my number from pay as you to pay as you go???, done this all again through o2chat, now 25 hours and still nothing, I think the next line will be cancel and stay on pay as you go
You need to use "keep my number" not a sim swap
http://www.o2.co.uk/help/phones-and-devices/how-to-keep-your-mobile-number -
Pay and go to pay monthly and keep your number all on o2, easy, B***ks
Had my NEW pay monthly sim, done a number swap on the web, then hung on 24 hours, nothing, web chat to O2, and there answer was, I was swaping my number from pay as you to pay as you go???, done this all again through o2chat, now 25 hours and still nothing, I think the next line will be cancel and stay on pay as you go
You need to use "keep my number" not a sim swap
http://www.o2.co.uk/help/phones-and-devices/how-to-keep-your-mobile-number -
CAML Query to get Items based on Year and Month From Date Column
Hi All,
* As we knew that there are default columns in calendar like Stattdate,Title,Location..etc.
* I required the CAML Query to get the list items of calender of particular Month and Year,So that I can get number of items or evetns are in Calendar
Can any one help me how can I do this using caml query
SamarHi Stuart,
Thanks for your response,I had chosen 2nd option of our above mention suggestion.But when I try to fetech the data from a calendar it is showing below error .I
had checked the below code with oter lists by changing Type to text and it worked fine.Can you please help me how can I fetech for the calulated columns
Error
"One or more field
types are not installed properly. Go to the list settings page to delete these
fields. "
Code:
string year="2014";
string month="February";
SPSite mysite = SPContext.Current.Site;
SPWeb myweb = mysite.OpenWeb();
try
SPList mylist = myweb.Lists["Calendar"];
SPQuery myquery = new SPQuery();
myquery.Query = @"<Where>
<And>
<Eq>
<FieldRef Name='Year'/>
<Value Type='Calculated'>"
+ year + @"</Value>
</Eq>
<Eq>
<FieldRef Name='Month'
/>
<Value Type='Calculated'>"
+ month + @"</Value>
</Eq>
</And>
</Where>";
SPListItemCollection totaltiems = mylist.GetItems(myquery);
Label1.Text= "Total Number of Items is "+" "+totaltiems.Count.ToString();
catch (Exception ee)
Label1.Text = ee.Message;
finally
myweb.Dispose();
Calculated Columns
Samar -
Calculate the number of days in a year excluding Saturday and Sunday
Hi All,
I need to get the number of days in a year excluding Saturday and Sunday for HR module and then subtract the public holidays.
Can some let me know how this needs to be done while loading data from one infocube to another.
Is there any Function module for the same so that i can write any start routines.
And also is there any table available for Tcode-SCAL with which i can write any start routines.
Kindly help me as soon as possible.
Regards,
KumarHi Harish
Refer to the screenshot for Import and Export parameters
Code
FUNCTION ZBI_FM_GET_HOLIDAYS .
*"*"Local Interface:
*" IMPORTING
*" VALUE(DATE_FROM) TYPE SCAL-DATE DEFAULT SY-DATUM
*" VALUE(DATE_TO) TYPE SCAL-DATE DEFAULT SY-DATUM
*" VALUE(FACT_CAL) TYPE SCAL-FCALID DEFAULT SPACE
*" VALUE(ONLYFACT_DAYS) TYPE CHAR1 OPTIONAL
*" EXPORTING
*" REFERENCE(HOLIDAYS) TYPE I
*" TABLES
*" DAY_ATTRIBUTES STRUCTURE CASDAYATTR
*" EXCEPTIONS
*" FACTORY_CALENDAR_NOT_FOUND
*" HOLIDAY_CALENDAR_NOT_FOUND
*" DATE_HAS_INVALID_FORMAT
*" DATE_INCONSISTENCY
DATA: LT_DAY_ATTRIBUTES TYPE TABLE OF CASDAYATTR WITH HEADER LINE.
DATA: LV_LINES TYPE SY-SUBRC.
DATA: DATE1 LIKE DATE_FROM,
DATE2 LIKE DATE_TO.
*if from date is gt to date then interchange the dates and multiply the result with -1.
IF DATE_FROM GT DATE_TO.
DATE2 = DATE_FROM.
DATE1 = DATE_TO.
ELSE.
DATE1 = DATE_FROM.
DATE2 = DATE_TO.
ENDIF.
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
FACTORY_CALENDAR = FACT_CAL
* HOLIDAY_CALENDAR = ' '
DATE_FROM = DATE1
DATE_TO = DATE2
LANGUAGE = SY-LANGU
* IMPORTING
* YEAR_OF_VALID_FROM =
* YEAR_OF_VALID_TO =
* RETURNCODE =
TABLES
DAY_ATTRIBUTES = LT_DAY_ATTRIBUTES
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 1
HOLIDAY_CALENDAR_NOT_FOUND = 2
DATE_HAS_INVALID_FORMAT = 3
DATE_INCONSISTENCY = 4
OTHERS = 5 .
IF SY-SUBRC = 0.
IF ONLYFACT_DAYS = 'X'.
DELETE LT_DAY_ATTRIBUTES WHERE FREEDAY EQ SPACE.
ELSE.
DELETE LT_DAY_ATTRIBUTES WHERE WEEKDAY LT 6.
ENDIF.
DESCRIBE TABLE LT_DAY_ATTRIBUTES LINES LV_LINES.
HOLIDAYS = LV_LINES.
* IF DATE_FROM GT DATE_TO.
* HOLIDAYS = HOLIDAYS * -1.
* ENDIF.
ELSEIF SY-SUBRC = 1.
RAISE FACTORY_CALENDAR_NOT_FOUND.
ELSEIF SY-SUBRC = 2.
RAISE HOLIDAY_CALENDAR_NOT_FOUND.
ELSEIF SY-SUBRC = 3.
RAISE DATE_HAS_INVALID_FORMAT.
ELSEIF SY-SUBRC = 4.
RAISE DATE_INCONSISTENCY.
ENDIF.
ENDFUNCTION. -
How to exclude 'Saturday' and 'sunday' In APEX 4.1 count(*)
Hi everyone am using APEX 4.1,
The Leave_transaction Table has the following Fields,
1.Leave_id
2.Emp_name
3.From_date
4.To_date
5.Remaining_days
The Emp_Master Table has the following columns,
1.Emp_id
2.Emp_Name
3.Remaining_days
select count(*) into days from (select dt
from(
select to_date(:p1_from_date, 'DD-Mon-YYYY') + rownum -1 dt
from dual
connect by level <= to_date(:p1_to_date, 'DD-Mon-YYYY') - to_date(:p1_from_date, 'DD-Mon-YYYY') + 1)
where to_char(dt,'fmday') not in ('sunday','saturday') dual;
If the Dates is between from_date and To_date comes in Saturday and sunday , it should exclude and return the count(*) remaining dates,
For example,
If the From_date is 04-may-2012'
and To_date is 08-may-2012,
Here the dates 5th may and 6th may are "saturday" and "sunday"
Then the remaining dates are(excluding sat,sunday and dates in holiday_table),
04-may-2012,
07-may-2012
08-may-2012.
so
count(*)
3I am using the above code but still it returning 5,
I think this
..where to_char(dt,'fmday') not in ('sunday','saturday')
code is not working.
Can anyone help me to solve my Issue.Hi theoa,
Actually this is my full code,
declare
days number(3);
ex_days emp_master.remaining_days%type;
new_rem_days emp_master.remaining_days%type;
begin
select count(*)
into days
from (select dt
from (select to_date (:p1_from_date, 'DD-Mon-YYYY',
'NLS_DATE_LANGUAGE=''english''')
+ rownum - 1 dt
from dual
connect by level <=
to_date (:p1_to_date, 'DD-Mon-YYYY',
'NLS_DATE_LANGUAGE=''english''')
- to_date (:p1_from_date, 'DD-Mon-YYYY',
'NLS_DATE_LANGUAGE=''english''')
+ 1)
where rtrim(to_char(dt,'fmDay', 'NLS_DATE_LANGUAGE=''english''')) not in
('Sunday','Saturday')
minus
(select holiday_start
from holiday_master)) dual;
apex_application.g_print_success_message := 'Hi '||:APP_USER||' '||'You are applied leave for'||' ' || days||' ' ||'days';
select remaining_days
into ex_days
from emp_master
where upper(emp_name) = upper(:APP_USER);
new_rem_days := ex_days - days;
update emp_master
set remaining_days = new_rem_days
where upper(emp_name) = upper(:APP_USER);
update leave_transaction
set remaining_days = new_rem_days
where upper(emp_name) = upper(:APP_USER)
and leave_id=
(select max(leave_id)
from leave_transaction);
end;The select statement which i mentioned above is working fine in database but not working in PAEX application. -
Hi,
Has anybody created a query to get the IBAN number.
If i join LFBK and TIBAN table and enter just vendor number it gives me list of all IBAN numbers which were changed. I would just like to get the current IBAN numebr in a vendor which is existing right now.
Can anyone let me know how to get this
JRTry the following plan. The plan is to create a new field to populate with the maximum of the dates and make it compare with the valid from dates. Strike the difference between these two fields. Pull only those records where the valid from date is equal to maximum date.
Go to the infoset. Click on Extras. Create an additional field say MAXDATE LIKE TIBAN-VALID_FROM.
Go to the coding section and give the following coding
<b>DATA: ZMAXDATE LIKE TIBAN-VALID_FROM.
CLEAR:ZMAXDATE, MAXDATE.
SELECT MAX( VALID_FROM ) FROM TIBAN INTO ZMAXDATE WHERE
BANKS = LFBK-BANKS AND
BANKL = LFBK-BANKL AND
BANKN = LFBK-BANKN.
MAXDATE = ZMAXDATE.</b>
Generate, save, assign the additional field to a field group.
Also include VALID_FROM field of TIBAN table into the field group.
Go to query, and create a local field called Difference, by enabling short names on. Give the ZMAXDATE field as MAX and TIBAN-VALID_FROM as VALFROM. Give the formula for the new field as difference between VALFROM - MAX.
Include the new field in the selection parameters. When running the report restrict the DIFFERENCE field = 0. -
Query to get total counts in the given scenario
Hi,
I am using Oracle 10g
I have a table A with following data
AgId Trm CD S
1000 100010 12-JAN A
1000 100019 20-MAR A
1000 100019 20-JUL D
1001 100011 25-JAN A
1001 100011 20-FEB D
1001 100011 23-MAR A
1001 100012 31-JAN A
1002 100013 14-FEB A
1002 100013 05-APR D
1002 100015 02-MAY A
1003 100014 03-MAR A
1003 100014 25-MAR D
1004 100016 22-MAY A
1004 100017 21-JUN A
1004 100018 01-JUL A
1005 100020 21-MAY D
1005 100020 21-JUL A
1005 100020 11-AUG D
Here the overall status of AgId '1000' is A as he is having atleast 1 Trm active
Similarly, status of AgId '1001' is A
status of AgId '1002' is A
But,status of AgId '1003' is D as his trm is disconnected after activation(according to date column'CD')
Then, status of AgId '1004' is A
and finally status of AgId '1005' is D again as his trm deactivated, activated and deactivated at last
So, considering these criteria can any one give me a query to get total no of AgId's who are 'Active' and similarly for 'Deactive'Hi,
when you put some code please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
CREATE TABLE ... etc.
{noformat}{noformat}
Also do not forget to put correct statements. Your insert were missing semicolon at the end.
Coming back to your problem, I assum that the current status of any trm is the latest status so I have done what follows:
{code:sql}
SELECT agid
, trm
, cd
, s
, ROW_NUMBER () OVER (PARTITION BY agid, trm ORDER BY cd) rn
, COUNT (*) OVER (PARTITION BY agid, trm) rn_tot
FROM a
ORDER BY agid, trm, cd;
Output:
AGID TRM CD S RN RN_TOT
1000 100010 12-JAN-12 A 1 1
1000 100019 20-MAR-12 A 1 2
1000 100019 20-JUL-12 D 2 2
1001 100011 25-JAN-12 A 1 3
1001 100011 20-FEB-12 D 2 3
1001 100011 23-MAR-12 A 3 3
1001 100012 31-JAN-12 A 1 1
1002 100013 14-FEB-12 A 1 2
1002 100013 05-APR-12 D 2 2
1002 100015 02-MAY-12 A 1 1
1003 100014 03-MAR-12 A 1 2
1003 100014 25-MAR-12 D 2 2
1004 100016 22-MAY-12 A 1 1
1004 100017 21-JUN-12 A 1 1
1004 100018 01-JUL-12 A 1 1
1005 100020 21-MAY-12 D 1 3
1005 100020 21-JUL-12 A 2 3
1005 100020 11-AUG-12 D 3 3I have used to columns rn and rn_tot to find the latest entry for a specific agid, trm
Using the query above I have done the following:
WITH mydata AS
SELECT agid
, trm
, cd
, s
, ROW_NUMBER () OVER (PARTITION BY agid, trm ORDER BY cd) rn
, COUNT (*) OVER (PARTITION BY agid, trm) rn_tot
FROM a
SELECT agid
, CASE WHEN SUM (CASE s WHEN 'A' THEN 1 END) > 0 THEN 'A' ELSE 'D' END s
FROM mydata
WHERE rn = rn_tot
GROUP BY agid;
Output:
AGID S
1000 A
1001 A
1002 A
1003 D
1004 A
1005 D
{code}
Which is listing the agid and its status if at least there is one trm with final status 'A' for that agid.
To sum up everything you can do simply like this:
{code:sql}
WITH mydata AS
SELECT agid
, trm
, cd
, s
, ROW_NUMBER () OVER (PARTITION BY agid, trm ORDER BY cd) rn
, COUNT (*) OVER (PARTITION BY agid, trm) rn_tot
FROM a
totdata AS
SELECT agid
, CASE WHEN SUM (CASE s WHEN 'A' THEN 1 END) > 0 THEN 'A' ELSE 'D' END s
FROM mydata
WHERE rn = rn_tot
GROUP BY agid
SELECT S, COUNT(*) cnt
FROM totdata
GROUP BY S;
Output:
S CNT
D 2
A 4
{code}
Regards.
Al -
SQL Query-return current month and the same month of last year
hello-
I would like to display the current month name, count of errors, year, and month number for both current year and previous year. Having trouble getting my query to display as following.....
Month CountofErrors Year MoNo
January 57 2015 1
January 155 2014 1
thank you!Its hard to answer without DDL and DML and sample data.
Give a try
select DATENAME(month,getdate()),Month(getdate()),YEAR(getdate()) ,COUNT(*) from dbo.errortable
where DATENAME(month,getdate())='January' and YEAR(getdate()) in(YEAR(getdate()),YEAR(getdate())-1)
group by DATENAME(month,getdate()),Month(getdate()),YEAR(getdate())
--Prashanth -
Getting all dates of a particular month and year
I want to get list of all dates of a particular month and year .
How to get using Calendar List?Create a Calendar object. Set it's month and year. Then call getActualMaximum(Calendar.DAY_OF_MONTH); on the Calendar object. That will tell you how many days are in the month of that year.
Maybe you are looking for
-
Replication of Users from portal to R/3
Hi, I would like to develop a portal functionnality that allows replication of users from portal to R/3. I know that the functionnality already exists in portal but we need to do another one because of special requirements. How could I find the java
-
To use GR Exchange rate during IV
Dear ALL: my customer has such request that they want the GR's exchange rate during IV automatically. Exchange Rate for invoice matching IR ( at Feb at 2.10 ) should be similar to GRN ( Jan at 2.00 exchange rate ). Customer does not want to fix the e
-
Theme Editor , default font for Analysis_ITEM (TABLE)
Hi, I'm using the theme editor to change some defaults fonts. I was able to change every font of a WebTemplate except the Font used by a table (Analysis_ITEM ). Can you tell me which item in the Theme editor affects de Font SIZE of the cells (values)
-
Where can I find a replacement remote for my sound blaster live 5
I have looked everywhere for a replacement but i cant seem to find one. if anyone could help please reply thanks.
-
Problem with folders when I click on some of these
Hi, I've got a problem when I click on some of my added folders on a system form (Service Contract). I added five new folder. The three first are perfect, I don't have anything to say about it, but the last two one cannot be focused correctly. By exa