Function to retrieve all days of the previous month.
Hi,
Yes, it's a monthly report i've been given the task to achieve.
So, all I need is all days of previous month (even if there is no data for this day)
I've been instructed to use the following code, but it does not return any value:
DECLARE
CURSOR CUR_LAST_DAY IS
SELECT TO_CHAR (LAST_DAY (ADD_MONTHS (SYSDATE, -1) ), 'DD')
FROM DUAL;
VVA_LAST_DAY VARCHAR2 (2);
VNU_JOUR NUMBER := 0;
BEGIN
OPEN CUR_LAST_DAY;
FETCH CUR_LAST_DAY
INTO VVA_LAST_DAY;
CLOSE CUR_LAST_DAY;
WHILE VNU_JOUR <= TO_NUMBER (VVA_LAST_DAY) - 1
LOOP
VNU_JOUR := VNU_JOUR + 1;
END LOOP;
END;
--CLOSE CUR_LAST_DAY
--DEALLOCATE CUR_LAST_DAY-----
On the other end, i've developped this code:
SELECT TO_CHAR(SYSDATE,'dd')
FROM DUAL
WHERE TO_CHAR(SYSDATE,'dd') >= to_char(to_date(to_char(ADD_MONTHS(SYSDATE, -1),'yyyy-mm')||'-01'),'yyyy-mm-dd')
AND TO_CHAR(SYSDATE,'dd') < to_char(LAST_DAY(to_date(to_date(to_char(ADD_MONTHS(SYSDATE, -1),'yyyy-mm')||'-01'),'yyyy-mm-dd')));Which is returning a null value. :(
Regards
Hello,
You want to retrieve complete days of last month from one query...so here it is..
SELECT
TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY') COMP_DATE,
TO_CHAR(TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY'),'DD') ONLY_DD,
TO_CHAR(TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY'),'MM') ONLY_MM,
TO_CHAR(TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY'),'YY') ONLY_YY
FROM DUAL
CONNECT BY LEVEL <= TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(SYSDATE,-1)),'DD'))I am not at database machine so therefore not tested.
But one thing keep in mind that this forum only for reports there is separate forum for sql and pl/sql.
Function to retrieve all days of the previous month.
-Ammad
Edited by: Ammad Ahmed on Apr 22, 2010 10:53 PM
Spelling Mistake
Similar Messages
-
Need to find the last day of the previous month
hi folks,
the code goes like this...
data: xt247 type t247,
monthn(30) type c,
monthnumber type i,
bforwardmonth type i.
call function 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = s_date
IMPORTING
last_day_of_month = e_date.
write: 'The last day of the month', e_date.
select single * from t247 into xt247
where spras = sy-langu
and mnr = e_date+4(2).
monthnumber = xt247-mnr.
write:' The month number', monthnumber.
determine the previous month.
bforwardmonth = monthnumber - 1.
From here I need to determine the last day of the previous month How can I do?
Thanks for your help.
SanthoshHi all,
here's the shortest solution:
REPORT z123.
PARAMETERS p_datum LIKE sy-datum DEFAULT sy-datum.
DATA ultimo LIKE sy-datum.
<b>ultimo = p_datum - p_datum+6(2).</b>
WRITE: / p_datum, 20 ultimo COLOR 2.
it's not my solution :
it's from <a href="http://www.abapforum.com/forum/viewtopic.php?t=1434&highlight=ultimo">Andrew_</a>
regards Andreas -
28th day of the previous month to 27th of the current month
Hi,
I am designing a report wherein the data should range from 12:01am on the 28th day of the previous month to 11:59 pm on the 27th of the current month.. This should be a dynamic one as this would be scheduled.
Any help will be greatly appreciated!
Thanks & Regards
BMCHi
Thanks for your reply and I have been using the same formula given by you but unfortunately it stopped giving the result. This is how i have given the syntax:
Create a new field name say From (this will calculate all the data of preceding month starting from 28th)
if not(month(CurrentDate)=1) then
date(year(CurrentDate),month(CurrentDate)-1,28)
else
date(year(CurrentDate)-1,12,1)
Creat an another field say To (this will calculate all the data of current month as of 27th)
if (month(CurrentDate)=1) then
date(year(CurrentDate),month(CurrentDate),27)
else
date(year(CurrentDate)-1,12,1)
Now create one more field say Time that will include the above two syntaxes.
{CHG_Change.Considered Res Time}>DateTime({@From}) and {CHG_Change.Considered Res Time}<=DateTime({@To})
This did work but seems now its not working.. Can you see if am missing out something here..
Regards
Cauvery -
How to get the last day of the previous month
Hello Team,
If my input date is today , then i need to find out the last day of the previous month for the same.
Can someone help me to find out .. how can this be done.
Regards,
RaviHi,
Try the below code.
// get a calendar object
GregorianCalendar calendar = new GregorianCalendar();
// convert the year and month to integers
int yearInt = Integer.parseInt(year);
int monthInt = Integer.parseInt(month);
int dayInt = Integer.parseInt(day);
// adjust the month for a zero based index
monthInt = monthInt - 1;
// set the date of the calendar to the date provided
calendar.set(yearInt, monthInt, dayInt);
int day = calendar.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
return Integer.toString(day);
Regards
Venkat -
Since I updated to 7.0.3 on my iphone 5, the battery drains by noon with little to no use. the battery would last all day before the update. Help. Thnx.
I noticed this too after I did the 7.0.3 update. What's going on, Apple? It's pretty frustrating.
-
Regarding the first day of the previous month
hi experts,
suppose the date is '010406' what i want that is der any function module so that i can get the first date of the previous month i.e '010306' plz let me know......or sud i add logic for that if yes plz help me........better to use own logic for your requirement....
suppose you have date field
data : date1 like sy-datum,
mon(2) type n,
year(4),
prev like sy-datum.
date1 = '20070720'.
mon = date1+4(2).
year = date1+0(4).
if mon ne '01'.
mon = mon - 1.
concatenate year mon '01' into prev.
else.
mon = '12'.
year = year - 1.
concatenate year mon '01' into prev.
endif.
write : / prev.
if the date is like your format i.e. 010406 then
data : date1(6) value '010406',
mon(2) type n,
year(4),
prev like sy-datum.
date1 = '20070720'.
mon = date1+2(2).
year = date1+4(2).
if mon ne '01'.
mon = mon - 1.
concatenate year mon '01' into prev.
else.
mon = '12'.
year = year - 1.
concatenate year mon '01' into prev.
endif.
write : / prev.
regards
shiba dutta -
Function to retrieve first day of the month.
Select (sysdate, 'IW') from dual
I know this takes the date to Monday. Is there a function like above which takes the date back to first Monday of the month ??
Thanks in advance.Hi,
NEXT_DAY is very handy, but it's dependent on NLS_DATE_LANGUAGE, and you can't pass an argument to override that.
TRUNC (dt, 'IW') does not depend on any NLS settings, so you might prefer this:
TRUNC ( 6 + TRUNC (SYSDATE, 'MONTH')
, 'IW'
) AS first_mondayThe 1st Monday of the month is the Monday on or before the 7th of the month. -
How to get Last Day of a Previous Month
Hi all,
I need to get Last Day of the Previous Month. I am able to get Current Month Last Day using Calendar.getActualMaximum(Calendar.DATE)
But I need previous Month's Last Day.
Thanks
Vamshi.Thanks all....
I have been trying the same and could get it.....
here is the code for that....
SimpleDateFormat simpleDate = new SimpleDateFormat("MM/dd/yyyy");
Calendar calendar = Calendar.getInstance();
month = calendar.get(Calendar.MONTH);
//year = calendar.get(Calendar.YEAR);
calendar.set(Calendar.MONTH, month-1);
calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
//lastDayOfMonth = calendar.getActualMaximum(Calendar.DATE);
System.out.Println("Previous Month End Date is :: " + simpleDate.format(calendar.getTime()));
this works....
thanks for ur replys.... -
Function module to get the same date of the previous month
Hi
Can anybody tell me how to get the
same date of the previous month.
example if i am entering date as 30 may 2007
i want the date as 30 april 2007CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = pa_end
days = '00'
months = '01'
signum = '-'
years = '00'
IMPORTING
calc_date = pa_end.
ENDIF.
nd try below FMs as well...
CCM_GO_BACK_MONTHS
HR_PT_ADD_MONTH_TO_DATE
RP_CALC_DATE_IN_INTERVAL
Hope it will solve your problem...
Reward points if useful..
Thanks & Regards
ilesh 24x7 -
For the previous month first day and last day
i want to schedule my reports from the last month first date to last month last date.
any body have queries for the while scheduling to uuse it.
Ex:sysdate() - today's date
first_day_of_month()- first day of current month
first day of last month ---?
last day of the last month ---?In the parameter, put this
{$FIRST_DAY_OF_MONTH()$}other values you can use in default parameter values are
{$SYSDATE()$} - to get current date
{$FIRST_DAY_OF_MONTH()$} - to get first day of the current month
{$FIRST_DAY_OF_YEAR()$} - to get first day of the current year
{$LAST_DAY_OF_MONTH()$} - to get last day of the current month
{$LAST_DAY_OF_YEAR()$} - to get last day of the current year
Re: Default date as first of month
TO get last day of last month
{$FIRST_DAY_OF_MONTH()-1$}You can add/subtract number with these functions and no other functions are available. -
In the last week when changing test notes in Outlook appointments or all day events, the changes appear on my PC, Iphone & Ipad, but when I print my calendar they do not print. I get the old text or deleted text from the printer copy of my calendar. What is going on?
Thanks Sig. The information is here: Anything useful stand out?
Battery Information:
Model Information:
Serial Number: 9G1130CJVD3MA
Manufacturer: DP
Device Name: bq20z451
Pack Lot Code: 0000
PCB Lot Code: 0000
Firmware Version: 0201
Hardware Revision: 0002
Cell Revision: 0158
Charge Information:
Charge Remaining (mAh): 5663
Fully Charged: Yes
Charging: No
Full Charge Capacity (mAh): 5663
Health Information:
Cycle Count: 59
Condition: Normal
Battery Installed: Yes
Amperage (mA): 261
Voltage (mV): 12574
System Power Settings:
AC Power:
System Sleep Timer (Minutes): 10
Disk Sleep Timer (Minutes): 10
Display Sleep Timer (Minutes): 10
Wake on AC Change: No
Wake on Clamshell Open: Yes
Wake on LAN: Yes
Current Power Source: Yes
Display Sleep Uses Dim: Yes
Battery Power:
System Sleep Timer (Minutes): 10
Disk Sleep Timer (Minutes): 10
Display Sleep Timer (Minutes): 2
Wake on AC Change: No
Wake on Clamshell Open: Yes
Display Sleep Uses Dim: Yes
Reduce Brightness: Yes
Hardware Configuration:
UPS Installed: No
AC Charger Information:
Connected: Yes
ID: 0x0100
Wattage (W): 60
Revision: 0x0000
Family: 0x00ba
Serial Number: 0x00262704
Charging: No -
How to show all days of the year 1900
how to show all days of the year 1900
As you show days for any other year.
Do you want to catch us on the fact year 1900 wasn't a leap year?
Regards
Etbin
select to_date('1.1.' || :the_year,'DD.MM.YYYY') + level - 1
from dual
connect by level <= to_date('31.12.' || :the_year,'DD.MM.YYYY') - to_date('1.1.' || :the_year,'DD.MM.YYYY') + 1*** not tested ***
Message was edited by: Etbin
user596003 -
hi,
I want a function module which could calculate the previous month's start date and end date...
Say todays date is like 29.05.2007(start date) it should return
01.04.2007 and 30.04.2007...
IS there any FM for this ... or how to go about this scenario ???
thanks in advance
sammSee the below Logic :
DATA :g_date(2) TYPE n, " Date
g_month(2) TYPE n, " Month
g_year(4) TYPE n , " Year
g_bill_low(10) TYPE n, " From date
g_bill_high(10) TYPE n, " To date
g_month1(2) TYPE n, " Month
g_year1(4) TYPE n, " Year
g_date1(2) TYPE n, " Date
g_year2(4) TYPE n, " Year
g_datum LIKE sy-datum. " System date
RANGES : r_bdate FOR vbrk-fkdat. " Billing date
g_datum = p_date + 10.
g_month = g_datum+4(2).
g_year = g_datum+0(4).
IF g_month = 1.
g_year = g_year - 1.
g_month = 12.
g_date = 1.
ELSE.
g_month = g_month - 1.
g_date = 1.
ENDIF.
Passing the date to billing date-low
CONCATENATE g_year g_month g_date INTO g_bill_low.
r_bdate-low = g_bill_low.
r_bdate-sign = 'I'.
r_bdate-option = 'BT'.
g_month1 = g_datum+4(2).
g_year1 = g_datum+0(4).
IF g_month1 = 1.
g_year1 = g_year1 - 1.
g_month1 = 12.
ELSE.
g_month1 = g_month1 - 1.
ENDIF.
CASE g_month1.
WHEN 1.g_date1 = '31'.
WHEN 3.g_date1 = '31'.
WHEN 4.g_date1 = '30'.
WHEN 5.g_date1 = '31'.
WHEN 6.g_date1 = '30'.
WHEN 7.g_date1 = '31'.
WHEN 8.g_date1 = '31'.
WHEN 9.g_date1 = '30'.
WHEN 10.g_date1 = '31'.
WHEN 11.g_date1 = '30'.
WHEN 12.g_date1 = '31'.
ENDCASE.
g_year2 = g_year1.
IF g_month1 = 2.
g_year2 = g_year2 MOD 4 .
IF g_year2 = 0.
g_date1 = 29.
ELSE.
g_date1 = 28.
ENDIF.
ENDIF.
Passing the date to billing date-high
CONCATENATE g_year1 g_month1 g_date1 INTO g_bill_high.
r_bdate-high = g_bill_high.
APPEND r_bdate.
Reward Points if it is helpful
Thanks
Seshu -
How to remove "all day" as the default setting in iCal?
How to remove "all day" as the default setting in iCal? The iCloud calendar works by double-clicking but the local behaves differently.
Hello Valerie,
the default - "all day" or "time based" - depends on the view in iCal. In month view the default is "all day",
in week view or day view it is a time interval, if you use "File -> New Event". If you add the event by double clicking into the calendar, it will depend on the section you are clicking - in the all day section you will add an all-day event, in the time-grid you will enter an event with start-end time.
Regards
Léonie -
My IPad will not turn on despite charging all night and all day. The Apple pops on but then shuts off again. It does this over and over. How can I fix this and get it up and running again?
Hey bellabeanbag,
Thanks for the question. The following resource outlines troubleshooting steps if your iPad is not responding:
iPad: Basic troubleshooting
http://support.apple.com/kb/TS3274
If iPad won't turn on, or the display stops responding
Follow these steps, testing after each:
1. Turn the iPad off and turn it on again. Press and hold the Sleep/Wake button on top of iPad for a few seconds, until a red slider appears. Then slide the slider. Then press and hold the Sleep/Wake button until the Apple logo appears.
2. Reset iPad. Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears.
If iPad still won't respond after you restore it
Follow these steps, testing after each:
1. If you receive an alert in iTunes while restoring your iPad, refer to this article for instructions on how to resolve common issues with updating and restoring.
2. If you cannot restore your iPad in iTunes, or if iTunes does not recognize the device, refer to this article for instructions on restoring using recovery mode.
Thanks,
Matt M.
Maybe you are looking for
-
Open BI Publisher Report After Submit
I have a page with 2 date fields, which are parameters for a report. I also have a button called RUN_REPORT. What I need to do is that the user puts the parameters in, then clicks RUN_REPORT. The page should submit (putting parameters into session st
-
External LCD Monitor Flickers for 10 - 15 minutes before it settles down
I have a Lenovo 3000 N100 with a samsung syncmaster 931B as the second monitor. When I activate the monitor, it flickers for around 20 minutes before it settles down. I have the resolution set at 1280x1024 32-bit color 60hertz refresh rate. I've had
-
Bose QC3 Headphone Modification a piece of cake
The Bose QC3 has a small rubber ring area just at the top edge of the connection pin. Took an exacto knife and cut around this ring down to the metal pin, then a sidewise cut so it could be removed. That ring seemed to be exactly the right amount of
-
hi , why the rest security question not shown in my browser to press on it and rest my forgotten answers ?? hellllp plzzzz
-
iphoto edit file://localhost/Users/xuanchieu12/Desktop/untitled%20folder/Screen%20Shot%2020 12-08-15%20at%2010.47.12%20PM.pngfile://localhost/Users/xuanchieu12/Desktop/unti tled%20folder/Screen%20Shot%202012-08-15%20at%2011.53.1