Help:Unable to get the Current Month Data
Hello Folks,
Hello Folks i have this scenario where i need to modify this code so that it has to return data from the Current month First Day to the previous Day if its a daily report and previous month data if its a monthly report.
BEGIN
if v_lowdate is null or v_highdate is null then
select to_number(to_char(sysdate, 'DD')) into v_cur_day from dual;
if v_cur_day < 25 then
-- this is for the previous month run
Select Add_Months(trunc(sysdate, 'MONTH'), -1)
INTO V_LOWDATE
FROM DUAL;
SELECT Last_Day(ADD_Months(Sysdate, -1)) INTO V_Highdate From Dual;
else
-- this is for the current month run
Select trunc(sysdate, 'MONTH') INTO V_LOWDATE FROM DUAL;
SELECT Last_Day(Sysdate) INTO V_Highdate From Dual;
end if;
end if;
I have replaced the above code with the code below but its still returning the previous month Data. Any help would be appreciated.
v_lob := get_admin_value(p_admin_procedure_name => 'CLIENT_DATAFEED_CODE',p_err_msg => v_error_text);
if v_lowdate is null or v_highdate is null then
v_cur_day := TO_CHAR (SYSDATE, 'DD');
IF report_type = 'D' -- Daily report
AND v_cur_day > '01' -- (except when run on 1st of the month)
THEN -- will cover from
v_lowdate := TRUNC (SYSDATE, 'MONTH'); -- 1st of this month to
v_highdate := TRUNC (SYSDATE - 1); -- yesterday
ELSIF report_type = 'M' -- Monthly report
OR ( report_type = 'D' -- (or Daily report
AND v_cur_day = '01' -- if run on the 1st of the month)
) -- will cover from
THEN
v_lowdate := ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
, -1
); -- 1st of last month
v_highdate := TRUNC (SYSDATE, 'MONTH') - 1; -- last day of last month
END IF;
END IF:
How are you testing this? It works for me, or at least generates the dates I think you want.
SQL> var fake VARCHAR2(25);
SQL> var report_type VARCHAR2(1);
SQL> exec :fake := '16-oct-2009'; :report_type := 'M';
PL/SQL procedure successfully completed.
SQL> DECLARE
2 v_cur_day VARCHAR2(2);
3 v_lowdate DATE;
4 v_highdate DATE;
5 fake_date DATE := TO_DATE(:fake, 'dd-mon-yyyy');
6 BEGIN
7 v_cur_day := TO_CHAR (fake_date, 'DD');
8 IF :report_type = 'D' AND v_cur_day > '01' THEN
9 v_lowdate := TRUNC (fake_date, 'MONTH'); -- 1st of this month to
10 v_highdate := TRUNC (fake_date - 1); -- yesterday
11 ELSIF :report_type = 'M' OR (:report_type = 'D' AND v_cur_day = '01') THEN
12 v_lowdate := ADD_MONTHS ( TRUNC (fake_date, 'MONTH'), -1); -- 1st of last month
13 v_highdate := TRUNC (fake_date, 'MONTH') - 1; -- last day of last month
14 END IF;
15 DBMS_OUTPUT.Put_Line('Low: '||TO_CHAR(v_lowdate, 'dd-mon-yyyy'));
16 DBMS_OUTPUT.Put_Line('High: '||TO_CHAR(v_highdate, 'dd-mon-yyyy'));
17 END;
18 /
Low: 01-sep-2009
High: 30-sep-2009
PL/SQL procedure successfully completed.
SQL> exec :report_type := 'D';
PL/SQL procedure successfully completed.
SQL> /
Low: 01-oct-2009
High: 15-oct-2009
PL/SQL procedure successfully completed.
SQL> exec :fake := '01-oct-2009';
PL/SQL procedure successfully completed.
SQL> /
Low: 01-sep-2009
High: 30-sep-2009
PL/SQL procedure successfully completed.John
Similar Messages
-
Oracle 11i release 2 error "Unable to get the current group"
Hi oracle gurus,
I have been trying to install oracle 11g rel 2 on HPUX 11.31 and i am getting the following error
# more installActions2010-01-06_10-27-37AM.log
oracle.install.ivw.db.driver.DBInstaller
-scratchPath
/u01/tmp/OraInstall2010-01-06_10-27-37AM
-sourceLoc
/u01/install/database/install/../stage/products.xml
-sourceType
network
-timestamp
2010-01-06_10-27-37AM
INFO: Loading data from: jar:file:/u01/tmp/OraInstall2010-01-06_10-27-37AM/ext/jlib/installcommons_1.0.0b.jar!/oracle/install/driver/oui/resource/ConfigComma
ndMappings.xml
INFO: Loading beanstore from jar:file:/u01/tmp/OraInstall2010-01-06_10-27-37AM/ext/jlib/installcommons_1.0.0b.jar!/oracle/install/driver/oui/resource/ConfigC
ommandMappings.xml
INFO: Restoring class oracle.install.driver.oui.ConfigCmdMappings from jar:file:/u01/tmp/OraInstall2010-01-06_10-27-37AM/ext/jlib/installcommons_1.0.0b.jar!/
oracle/install/driver/oui/resource/ConfigCommandMappings.xml
SEVERE: [FATAL] An internal error occurred within cluster verification framework
Unable to get the current group.
Refer associated stacktrace #oracle.install.commons.util.exception.DefaultErrorAdvisor:11
INFO: Advice is ABORT
SEVERE: Unconditional Exit
INFO: Adding ExitStatus FAILURE to the exit status set
INFO: Finding the most appropriate exit status for the current application
INFO: Exit Status is -1
INFO: Shutdown Oracle Database 11g Release 2 Installer
$
>>
# more oraInstall2010-01-06_10-27-37AM.err
---# Begin Stacktrace #---------------------------
ID: oracle.install.commons.util.exception.DefaultErrorAdvisor:11
oracle.cluster.verification.VerificationException: An internal error occurred within cluster verification framework
Unable to get the current group
at oracle.cluster.verification.ClusterVerification.<init>(ClusterVerification.java:200)
at oracle.cluster.verification.ClusterVerification.getInstance(ClusterVerification.java:294)
at oracle.install.driver.oui.OUISetupDriver.load(OUISetupDriver.java:407)
at oracle.install.ivw.db.driver.DBSetupDriver.load(DBSetupDriver.java:161)
at oracle.install.commons.base.driver.common.Installer.run(Installer.java:216)
at oracle.install.ivw.db.driver.DBInstaller.run(DBInstaller.java:126)
at oracle.install.commons.util.Application.startup(Application.java:869)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:164)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)
at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:265)
at oracle.install.ivw.db.driver.DBInstaller.startup(DBInstaller.java:114)
at oracle.install.ivw.db.driver.DBInstaller.main(DBInstaller.java:132)
---# End Stacktrace #-----------------------------
<<
$ uname -a
HP-UX rx2600 B.11.31 U ia64 <XXXXXXXX> unlimited-user license
# swlist | grep -i oe
HP-Caliper-PERF C.11.31.04 HP Caliper OE Bundle
HP-WDB-DEBUGGER C.11.31.04 HP DEBUGGER OE Bundle
HPUX11i-DC-OE B.11.31.0903 HP-UX Data Center Operating Environment
# swlist | grep -i qpk
QPKBASE B.11.31.0903.334a Base Quality Pack Bundle for HP-UX 11i v3, March 2009
# swlist -l product | grep -i c++
ACXX C.06.20 HP C/aC++ Compiler
C-ANSI-C C.06.20 HP C/aC++ Compiler
PHSS_37501 1.0 aC++ Runtime (IA: A.06.16, PA: A.03.76)
PHSS_39824 1.0 HP C/aC++ Compiler (A.06.23)
i start the installation as oracle and my group and user id is
$ id
uid=109(oracle) gid=102(oinstall) groups=101(dba),104(asmdba)
Please let me know what else do i need, we might have to use the hardware for testing another application so i am limited in terms of time constraints
any help is much appreciated, Thank you!!
Regards,
Dasjith
Edited by: user10247524 on Jan 6, 2010 7:52 AMHi Stig Sundqvist
Where can i find MOS Doc 983713.1 ??You have to login https://support.oracle.com/CSP/ui/flash.html and you have to CSI account. This site is oracle site for tech. documents for can rise SR etc.. for more details please check
What is CSI:
Re: Installing Oracle Database 10.2.0.4
And how do i do to fix this problem ????Login metalink then find upper note and follow document
Hope it helps
Regard
Helios -
How to get the current month number
Hi everyone,
Does anybody know how to get the current month number in Oracle Discoverer Worksheet calculation?
I try to use EUL_DATE_TRUNC(CURRENT_DATE, 'MM'), but instead I got 01-AUG-00.
If I change the data display format to MM, it will give me "08" but if I use TO_NUMBER function to convert it to number I get error "invalid number"
Is there anyway to get the current month value in number? ThanksScott,
Thank you so much! It works perfectly! :)
Hope you have a great day ahead!
Cheers,
Angeline -
How to Get the current month at timezone UTC-10
Hi All,
can you please let me know How to Get the current month at timezone UTC-10.
Function module ? which date and time needs to pass.Hi,
Try with following code.
DATA zdate TYPE D.
DATA ztime TYPE T.
CALL FUNCTION 'ISU_DATE_TIME_CONVERT_TIMEZONE'
EXPORTING
x_date_utc = sy-datum
x_time_utc = sy-uzeit
x_timezone = 'UTC-10'
IMPORTING
Y_DATE_LCL = zdate
Y_TIME_LCL = ztime
EXCEPTIONS
GENERAL_FAULT = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE : zdate, / ztime.
Thank you,
Sekhar. -
How to get the current month value for a customer exit variable?
How to get the current month value for a customer exit variable?
And also if we have an InfoObject with date value (including date, month, year), then how to derive the month value from this date type of Char.?
Thanks!Hi Kevin,
Check here........
Re: Customer Exist for "From Current Date To Month End"
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a
Cal month
Regards,
Vijay. -
I need to get the Current System Date and time in the format
I need to get the Current System Date and time in the format
*6/24/2009 11:30:29 AM*
How do i do it ?I seem to be saying this a lot lately.
Google is your friend.
I googled "java current date format" and SimpleDateFormat featured prominently in the results. -
How to get the current month starting date and ending date by default ?
Hello Creators,
This is my requirement, kindly do the needful, Please dont gimme any links i've no access for other sites, gimme the right solution.
My Requirement :
Creation Date (VBAK-ERDAT) - Select Option. By default, the program should run for the current Month ie between the starting and ending date of the current month when the program is run. Today the date is 18th using sy-datum we can bring the current date by calling it in the initialization event, but the requirement is it should not give me the current date, it should only give me the month starting date and the end date. Kindly help.
Thanks in advance ...DATA: gv_datum LIKE vbak-erdat.
SELECT-OPTIONS: so_date FOR gv_datum.
INITIALIZATION.
CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
EXPORTING
iv_date = sy-datum
IMPORTING
ev_month_begin_date = so_date-low
ev_month_end_date = so_date-high.
so_date-option = 'BT'.
APPEND so_date.
START-OF-SELECTION.
Hope this solves the issue. Don't forget to be generous
Cheers,
Sougata. -
Help needed in getting the previous Quarter Data
Hello folks,
I have this procedure where i have to modify the current procedure in the following manner:
I need to get rid of the variables p_start and p_end so that i cannot see them in the crystal report and include the Frequency in the procedure to get the Data based on the Dates.
and Main requirement is" If the Frequency is Quarterly " it should get the previous quarter Data, if "Frequency is monthly" it should return the previous month data.Can anyone please let me know where shud i make changes. Am including the procedure for refernce. Any help is appreciated
Thanks a millioin,
CREATE OR REPLACE PROCEDURE hcsc_recovery_report_h(report_record in out cr_return_types.gen_cursor,
p_start string,
p_end string)
IS
v_startdate date;
v_enddate date;
BEGIN
v_startdate := to_date(p_start, 'YYYY/MM');
v_enddate := last_day(to_date(p_end, 'YYYY/MM'));
open report_record for
select --distinct r.recovery_id
r.event_id,
r.event_case_id,
c.client_id,
c.client_code,
c.client_name,
b.branch_group_code,
b.branch_group_description,
g.employer_group_code,
g.employer_group_name,
e.client_policy_identifier,
e.date_of_incident,
e.event_type_code,
sum(nvl(r.amount, 0)) as amt_received,
nvl(sum(case
when r.amount >= 0 then
rd.fees
else
rd.fees * (-1)
end),
0) as fees,
ec.close_date, *001* commented
(case
when ec.close_date <= to_date(to_char(v_enddate, 'MMDDRRRR') || '235959',
'MMDDRRRR HH24MISS') then
ec.close_date
else
null
end) as close_date, --*001* added
get_case_value(ec.event_id, ec.event_case_id, v_enddate) as case_value,
nvl(etl.fee_percent_flag, 'N') workmans_comp,
max(to_char(r.recovery_date, 'FMMonthYYYY')) Year_Month,
max(to_char(r.recovery_date, 'YYYYMM')) Y_M,
max(to_date(to_char(r.recovery_date, 'MMYYYY'), 'MM/YYYY')) date_MY
from recovery r,
recovery_detail rd,
event e,
client c,
branch_group b,
employer_group g,
event_case ec,
event_type_lookup etl
where r.event_id = e.event_id
and r.event_case_id = ec.event_case_id
and ec.event_id = e.event_id
and rd.recovery_id(+) = r.recovery_id
and r.recovery_date between v_startdate and
to_date(to_char(v_enddate, 'MMDDRRRR') || '235959',
'MMDDRRRR HH24MISS')
and e.client_id = c.client_id
and g.client_id = c.client_id
and b.client_id = c.client_id
and g.employer_group_id(+) = e.employer_group_id
and b.branch_group_id(+) = g.branch_group_id
and e.event_type_code = etl.event_type_code -- SST 130852 04/14/09
group by r.event_id,
r.event_case_id,
c.client_id,
c.client_code,
c.client_name,
b.branch_group_code,
b.branch_group_description,
g.employer_group_code,
g.employer_group_name,
e.client_policy_identifier,
e.date_of_incident,
e.event_type_code,
ec.close_date,
get_case_value(ec.event_id, ec.event_case_id, v_enddate),
nvl(etl.fee_percent_flag, 'N')
having sum(nvl(r.amount, 0)) <> 0
order by c.client_code,
b.branch_group_code,
g.employer_group_code,
r.event_case_id;
Edited by: user11961230 on Oct 20, 2009 9:02 AMuser11961230 wrote:
1. I want to get rid of the p_start and p_end. So how do i declare the v_startdate and v_enddate in the following part?
v_startdate := to_date(p_start, 'YYYY/MM');
v_enddate := last_day(to_date(p_end, 'YYYY/MM'));I'm not sure what you mean by "declare".
In PL/SQL, "declare" means state (at the beginning of a block) that there will be a certain variable with a certain name (such as v_startdate) and datatype (such as DATE). You're already declaring the variables v_startdate and v_enddate correctly, right before the BEGIN statement.
Declaring a variable is not the same as initializing it, that is, giving it a value for the first time. Your next question seems to be about initializing..
2. where exactly shud i include the logic that u have mentioned. sorry a dumb questionIn place of the two assignment statments that reference p_start and p_end.
3. This time am gonna use frequency instead of report_type so that i will get rid of the p_start and p_end from the procedure.Do you mean you want to pass an argument (called frequency) that tells if you want a quarterly or a mionthly report, just like the variable report_type in my example?
If so, replace report_type in my example with frequency.
I think you want something like this:
CREATE OR REPLACE PROCEDURE hcsc_recovery_report_h
( report_record in out cr_return_types.gen_cursor
, frequency IN VARCHAR2
IS
-- Declare local variables:
v_startdate date;
v_enddate date;
BEGIN
-- Initialize v_startdate and v_enddate, depending on frequency
IF frequency = 'QUARTERLY'
THEN
v_startdate := TRUNC ( ADD_MONTHS (SYSDATE, -3)
, 'Q'
v_enddate := TRUNC (SYSDATE, 'Q');
ELSIF frequency = 'MONTHLY'
THEN
v_startdate := TRUNC ( ADD_MONTHS (SYSDATE, -1)
, 'MM'
v_enddate := TRUNC (SYSDATE, 'MM');
END IF;
-- Subtract one second from v_enddate
v_enddate := v_enddate - ( 1
/ (24 * 60 * 60)
open report_record for
select --distinct r.recovery_id
r.event_id,
and r.recovery_date BETWEEN v_startdate
AND v_enddate
...When you post formatted text on this site (and code should always be formatted), type these 6 characters:
(small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
Edited by: Frank Kulash on Oct 20, 2009 2:37 PM
Changed query to use BETWEEN -
How to get the current month for a variable based on info object 0FISCPER3
Hie Gurus
I am working on the financial reports i am failing to derive the Current month from the variable based on infobject 0FISCPER3 PERIOD .
I would also like to get the same month from the prevoius year. Any ideas?If I understood correctly, you need in your repot
Current Month Plan This year || YTD Plan This Year || Current Month Plan Last Year || YTD Plan Last Year
Your variable 0I_FISCPER3 must be on the object 0FISCPER3 which is nothing but just the Fiscal Period. This variable is a user entry mandatory Interval variable.
if you are entering a range in the input screen for this variable, you will get cumulative values. If you just need to get the value for a month in first column your report, you will have to create another variable of type Customer Exit which will read the "To value" entered for the variable 0I_FISCPER3 and columns for Current Month should be restricted on this variable.
if you are entering a single value in the selection screen of this variable, current month column should be restricted on this variable with "Equal To" operation and YTD colmns should be restricted to "Less Than Equal to" operator with this variable.
0FISCPER3 just have posting period and not year, so you will have to use varialbes for 0FISCYEAR separately.
Please let us know if it helps or if you are using some other variable based on 0FISCPER3 or 0FISCPER.
Regards,
Gaurav -
Is there any predefined functions to get the current month info?
Hi,
I have a business rule which is used to calculate the budget of current month. Right now, I set the current month as a variable, which will need to be changed every month, I know it's stupid, I am new to this area, so I am thinking is there any better way to do this?
Any inputs is appreciated.
Thanks
TonyUsing substitution variables for current month is perfectly acceptable and widely used.
Cheers
John
http://john-goodwin.blogspot.com/ -
Query to get the current DB date, not server date
Hi,
We have few DB in one server, but each DB have different timezone.
How can I get the query to generate the current date in each DB?
ThanksHi,
Try this query:
SELECT DB_NAME() AS DataBaseName,getdate()
Thanks & Regards,
Nagarajan -
Please help - Unable to get the cluster database home page
I have both the RACDB1 & RACDB2 instances running (and the 2 listeners also) . But I do not get the the cluster database home page. Instead I get startup/shutdown page. EM later confirms both instances are up.
But how do I connect to the RACDB database to perform any admin work from within EM ?
Any help is appreciated.
Thank you.Ehm. Before placing? At that point ID doesn't know anything at all about the PDF.
var myPDFFile = File.openDialog("Choose a PDF File");
myPDFFile.execute();
Then check the lower left bottom -- it should display the page size.
Why not first place the file and then check its size? You can always move it to the right position after placing.
Oh, by the way: "a PDF" doesn't have a "page size". Each single page in a PDF can have a page size of its own. -
How can i pull out data from a spreadsheet only from the current month?
Data is constantly being fed into a spreadsheet using a VI, this data comprises of such things as month, year, weights, std dev, etc. I want to do some data manipulation on the current months data while the VI is running, how can I pull out only the data relating to the current month? Each input into the spreadsheet stores the values for that run on one row, and there are perhaps 150 runs each month
Any thoughts are greatefully received
Thanks
Ross
Attachments:
Results.xls 1 KBHi Ross,
I thought I would go away and make you an example VI for the results xls that you have sent me.
Here it is: I have added a few comments here and there but if you need more info please don't hessitate to post back on the forum
Hope if helps
AdamB
National Instruments
Applications Engineering Team Leader | National Instruments | UK & Ireland
Attachments:
MonthExtract.vi 43 KB -
How to get the currrent month and year from a new date object
If I create a new Date object as "d",
java.util.Date d = new java.util.Date();how can I format the date to get the current Month as 'Jan' and the current year as '2008'. So if I have something like d.getMonth() gets the current month as 'Oct' and d.getYear() gets '2008'
Thanks,
Zub[Read the flamin' manual you must. Hmm.|http://en.wikipedia.org/wiki/RTFM]
~~ Yoda.
Well no actually, he didn't say that, but he should have.
Cheers. Keith.
PS: Don't say that to a 7 foot pissedOff wookie when he's got his head stuck in a smoking hyperdrive, and you're being chased by a S-class battle cruiser... Ask Yoda how he got to be so short.
PPS: It is the SimpleDateFormat you seek ;-)
Edited by: corlettk on 14/10/2008 22:37 ~~ Also far to slow... but funny. -
Current Months Data - Automatic
How to run a YTD report which will automatically show the current months data with no variable prompt for the same...?
Is there any such variable which will run a report only for current months data.I dont think there is a std variable for current period. rather you can use fiscalyear/period time char and use 0FPER to derive current fiscalyear/period
Maybe you are looking for
-
How to generate CSV ouput from JD Edwards 8.11 using rtf template
Hi, I have a report "Critical Date Report" - R15611 in JD Edwards 8.11. This report has to be generated as CSV output from BI Publisher which is embedded to JDE. why we choose the output in BI Publisher is to move some of the data displaying to diffe
-
Using factory calendars in BI transformations
Hello All, Do we have the option of using factory calendars in BI transformations, like we had in 3.x version update rules. I did not see any option for choosing the factory calendar, so i guess we will have to use function modules. Please let me kno
-
I'm having problems with all my apps and it's freezing my videos on face book
this new program by iOS 8 is really messing up all my apps it's also freezing my videos on facebook and on my apps it won't let me close some of them
-
Why don't the Adobe Acrobat 10.1.6 and Adobe Reader 9.5.4 patches update the version on the exe file ? My vulnerability reports show these installations are not patched when they really are.
-
I can't hear the other person ?
Just bought the i Phone 4 and I can't hear the caller, the volume is set to max with the button on the side but it is still to quiet. Please Help