To calculate the last day of a week
I have this problem.
I must calculate the last day (saturday) of a week, if I have somewhere day of a week.
For example
if today is Thursday 08/03 how can calculate Saturday 10/03?
Thank's a lot!!!
The day number given previously is territory dependant. So, in France, the last day of week (day 7) is sunday instead of saturday...
You can try to work with next_day function, which is more independant :
SQL> select to_char(sysdate,'d') from dual;
T
4
SQL> select next_day(sysdate-1,'saturday') from dual;
NEXT_DAY
10/03/07
SQL> alter session set nls_territory='america';
Session altered.
SQL> select to_char(sysdate,'d') from dual;
T
5
SQL>
SQL> select next_day(sysdate-1,'saturday') from dual;
NEXT_DAY(
10-MAR-07
SQL> Nicolas.
Similar Messages
-
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() ); -
Formula to calculate the last day of the subsequent month
Hi - I am trying to create a formula in CR9 that will take a date field and translate it to the last day of the subsequent month. For example, I have a date of today, 2/3/2009. I need it to print on the report 3/31/2009. I have made some progress to get me the 1st day of the subsequent month, but I need it to be the last day of the subsequent month.
The formula I am have currently is:
DateSerial(Year({Name.JOIN_DATE}), Month({Name.JOIN_DATE}) + 1, 0)+1
this will give me 3/1/2009, but I need 3/31/2009.
Any help appreciated.
Thanks!Hi Joe,
You can use the following logic which also takes into account the extra day in a leap year. You will need 5 formulas for this:
First create a formula that calculates current month, call it @Current Month MM
Month(Name.JOIN_DATE)+1
Next create another formula called @Current Month Start Date which will give you the beginning of the month.
totext(Date (year(currentdate),tonumber({@Current Month MM}) ,1 ))
Next create another formula called @Current Year yyyy
Year(Name.JOIN_DATE)
Next, create a formula called @DaysofMonth with the following logic:
if tonumber({@Current Year yyyy}) mod 4 = 0 then
choose(month(date({@Current Month Start Date})),31,29,31,30,31,30,31,31,30,31,30,31) else
choose(month(date({@Current Month Start Date})),31,28,31,30,31,30,31,31,30,31,30,31)
Lastly create a formula called @Ending Date of Month
totext(Date (year(currentdate),tonumber({@Current Month MM}) ,{@DaysOfMonth} ))
I hope this information proves useful.
Regards,
Zack H.
Edited by: Zack H on Feb 3, 2009 5:34 PM
Edited by: Zack H on Feb 3, 2009 5:38 PM -
How to get the last day of the week?
Hii
i can get the calender week number for any given date using
SELECT to_char(to_date('04/04/2011','MM/DD/YYYY'),'WW') FROM dual
can any body tell me, how to get the last day of that week ?
and the answer should be 04/08/2011(8th april )
thanks
San
Edited by: sandeep9 on Apr 4, 2011 3:50 AMHi, San,
Here's one way:
WITH sample_data AS
SELECT DATE '2011-04-04' AS dt
FROM dual
SELECT dt
, TO_CHAR (dt, 'WW') AS week_num
, NEXT_DAY ( dt - 1
, TO_CHAR ( TRUNC (dt, 'YEAR') - 1
, 'Day'
) AS end_o_week
FROM sample_data;Another way is to use date arrithmetic:
WITH sample_data AS
SELECT DATE '2011-04-09' AS dt
FROM dual
SELECT dt
, TO_CHAR (dt, 'WW') AS week_num
, TRUNC (dt, 'YEAR')
+ (7 * CEIL ( (dt - (TRUNC (dt, 'YEAR') - 1))
/ 7
- 1 AS using_date_arithmetic
FROM sample_data; -
How to get the last day according to fiscal period input in selection scree
Hello expert
how to get the last day of fiscal period input.
the fiscal period inculdes 1-16
when fiscal period is greater than 12, only calculate the last day of 12nd month
your solution will be apprecaited, FM existing?
thank you
KevinHi,
when you give a particular date in any month
the following fm will give you the last date of that month
here you can give
R_FDATE-HIGH as 01 and month as the period you wnat and year for current year
concatenates '01' month year into r_fdate-high separated by '.'.
then it will give g_ltdt for that month and year which wil be the last date of that month
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = R_FDATE-HIGH
IMPORTING
LAST_DAY_OF_MONTH = G_LTDT
EXCEPTIONS
DAY_IN_NO_DATE = 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.
thanks & regards,
Venkatesh -
How to get the First day in a Week in a Fiscal Year
Hi guys,
I have a Requirement to calculate the First day in a Week in a Fiscal year .
The FM GET*FIRST_DATE and all are for Calender year.
Is there any FM to calculate the First in a Week in a Fiscal year.
For eg. They will give 200826.
In this 26 is the Week.
I need to find the First date value in that Week.
Thanks,
GokulHi Gokul...
Instead of using the funtion module you can just write the 3 statements of code to get the first day of the week.
Its similar to the above one but instead of writing case statement you can achive the following.
data : w_res type i,
w_data type d,
w_res = w_date mod 7.
w_date = w_date - w_res.
write w_date.
This works.
Regards,
Siddarth -
Getting the Last day for a given week number
Dear Gurus,
I want to find the Last day of a given week number.
Can anyone help me out.
Regards
Madhu KHere I dont want to pass date,
If I give Week Number, Can I get that Week Numbers
Last date and First Date.
test@ORA10G>
test@ORA10G> -- this query fetches the start and end dates for a specified week in the current year
test@ORA10G>
test@ORA10G> select
2 wk as week,
3 min(dt) as start_date,
4 max(dt) as end_date
5 from (
6 select
7 trunc(sysdate,'yyyy')+level-1 as dt,
8 to_char(trunc(sysdate,'yyyy')+level-1,'ww') as wk
9 from dual
10 connect by level <= trunc(add_months(sysdate,12),'yyyy') - trunc(sysdate,'yyyy')
11 )
12 where wk = &week_number
13 group by wk;
Enter value for week_number: 1
WE START_DAT END_DATE
01 01-JAN-08 07-JAN-08
test@ORA10G>
test@ORA10G> /
Enter value for week_number: 23
WE START_DAT END_DATE
23 03-JUN-08 09-JUN-08
test@ORA10G>
test@ORA10G> /
Enter value for week_number: 52
WE START_DAT END_DATE
52 23-DEC-08 29-DEC-08
test@ORA10G>
test@ORA10G> /
Enter value for week_number: 53
WE START_DAT END_DATE
53 30-DEC-08 31-DEC-08
test@ORA10G>
test@ORA10G>pratz
can be shortened further:
test@ORA10G>
test@ORA10G> select
2 to_char(trunc(sysdate,'yyyy')+level-1,'ww') as wk,
3 min(trunc(sysdate,'yyyy')+level-1) as start_dt,
4 max(trunc(sysdate,'yyyy')+level-1) as end_dt
5 from dual
6 where to_number(to_char(trunc(sysdate,'yyyy')+level-1,'ww')) = &week_number
7 connect by level <= trunc(add_months(sysdate,12),'yyyy') - trunc(sysdate,'yyyy')
8 group by to_char(trunc(sysdate,'yyyy')+level-1,'ww')
9 /
Enter value for week_number: 1
WK START_DT END_DT
01 01-JAN-08 07-JAN-08
test@ORA10G>
test@ORA10G> /
Enter value for week_number: 53
WK START_DT END_DT
53 30-DEC-08 31-DEC-08
test@ORA10G>
test@ORA10G> /
Enter value for week_number: 23
WK START_DT END_DT
23 03-JUN-08 09-JUN-08
test@ORA10G>
test@ORA10G> /
Enter value for week_number: 14
WK START_DT END_DT
14 01-APR-08 07-APR-08
test@ORA10G>
test@ORA10G>Message was edited by:
pratz -
Generating the last day of the week
HI All,
I have the Year value (for eg 2002, 2006) and the week number value in the year ( for eg : 32, 52) . Based on this information, how can I get the last day of the particular week.
for eg What is the last day of the week - 2002,32
Any pointer would be great.
Thanks and Regards
VenkatOr try this:
SQL> WITH t AS
(SELECT 2006 YEAR, 1 week
FROM DUAL
UNION ALL
SELECT 2002 YEAR, 32 week
FROM DUAL
UNION ALL
SELECT 2005 YEAR, 52 week
FROM DUAL
UNION ALL
SELECT 2006 YEAR, 52 week
FROM DUAL)
SELECT YEAR,
week,
CASE
WHEN TO_CHAR (TRUNC (TO_DATE (YEAR, 'RR'), 'RR'), 'IW') != 1
THEN TRUNC (TRUNC (TO_DATE (YEAR, 'RR'), 'RR') + 7, 'IW')
ELSE TRUNC (TRUNC (TO_DATE (YEAR, 'RR'), 'RR'), 'IW')
END
+ 6 + (week - 1) * 7 LAST_DAY
FROM t
YEAR WEEK LAST_DAY
2006 1 08-JAN-06
2002 32 11-AUG-02
2005 52 01-JAN-06
2006 52 31-DEZ-06
4 rows selected. -
How do I set a reminder for the last day of every month
Have I missed something? But how do you set a reminder for the last day of every month to recurr indefinatley in iOS6? Sorry if this is really simple but I just can't seem to work it out. Any help gratefully received.
Hey Mattye88 not sure if you have seen but actully you can do this, but for some reason you have to use Siri. If you bring up Siri and say "set a reminder ever 4 weeks from next wednesday to check the gas meter" it will set one and it will work just fine, I have reminders to water a Bonsai every three days and it works fine it just shows as custom repeat on the user interface. Alas it seems you can not use Siri to set one for the end of the month though which is why I am in this threed. Still hope it helps you to know how to sort this problem atleast.
-
How to get the last day of calweek
Hi Guys,
Is there any function module to get the last day of the calendarweek.
I want to show that last date of calweek in my column heading.You can use the Calender class...
Calendar c = Calendar.getInstance();
and then something like...
c.add(c.MONTH, 1);
int dayOfMonth = c.get(Calender.MONTH);
c.add(c.DAY_OF_MONTH, - (dayOfMonth-1) );
other usefull functions are:
System.out.println(" YEAR : " + c.get(Calendar.YEAR));
System.out.println(" MONTH : " + c.get(Calendar.MONTH));
System.out.println(" DAY_OF_MONTH : " + c.get(Calendar.DAY_OF_MONTH));
System.out.println(" DAY_OF_WEEK : " + c.get(Calendar.DAY_OF_WEEK));
System.out.println(" DAY_OF_YEAR : " + c.get(Calendar.DAY_OF_YEAR));
System.out.println(" WEEK_OF_YEAR : " + c.get(Calendar.WEEK_OF_YEAR));
System.out.println(" WEEK_OF_MONTH : " + c.get(Calendar.WEEK_OF_MONTH));
System.out.println(" DAY_OF_WEEK_IN_MONTH : " + c.get(Calendar.DAY_OF_WEEK_IN_MONTH));
System.out.println(" HOUR : " + c.get(Calendar.HOUR));
System.out.println(" AM_PM : " + c.get(Calendar.AM_PM));
System.out.println(" HOUR_OF_DAY (24-hour): " + c.get(Calendar.HOUR_OF_DAY));
System.out.println(" MINUTE : " + c.get(Calendar.MINUTE));
System.out.println(" SECOND : " + c.get(Calendar.SECOND));
System.out.println();*/ -
How to get the last day of the next month?
Hi all.
I need to get the last day of the next month. E.g. if the date is 20.03.2008 I need to get 30.04.2008.
Is there any FM for it?
TIA, Nikolai.hi Nikolai,
pls. have a look athe following piece of code:
PARAMETERS : p_date TYPE sy-datum.
DATA : gv_res TYPE sy-datum.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
* DAYS = '0'
months = '2'
start_date = p_date
IMPORTING
result_date = gv_res.
==> Now you have (gv_res) 2 months later as today
gv_res+6(2) = '01'. ==> gv_res is first day of next-next month
gv_res = gv_res - 1. ==> gv_res is last day of next month
hope this helps
ec -
How to get the last day of the payroll period
Hi all,
I need to get the last day of the payroll period e.g. last day of Jan 2007 is 31 Jan 2007. Can anyone suggest as to how to get it?
Thanks,
MadhuT549S contains the payroll periods with pay date. T549Q contains the begin and end dates of the payroll period.
You can select from the appropriate table (or from both depending on your given data) to get the end date of the period.
Hope that helps.
Mary -
How to get the last day of a month?
HI,
I want to know how to get the last day of a month.
In my JClient form, I tried to get it by using oracle.sql.Date method, that is:
lastday=oracle.sql.Date anydate.lastDayOfMonth();
But it does not work. The result is lastday=anydate.
Why?
StephenYou can use the Calender class...
Calendar c = Calendar.getInstance();
and then something like...
c.add(c.MONTH, 1);
int dayOfMonth = c.get(Calender.MONTH);
c.add(c.DAY_OF_MONTH, - (dayOfMonth-1) );
other usefull functions are:
System.out.println(" YEAR : " + c.get(Calendar.YEAR));
System.out.println(" MONTH : " + c.get(Calendar.MONTH));
System.out.println(" DAY_OF_MONTH : " + c.get(Calendar.DAY_OF_MONTH));
System.out.println(" DAY_OF_WEEK : " + c.get(Calendar.DAY_OF_WEEK));
System.out.println(" DAY_OF_YEAR : " + c.get(Calendar.DAY_OF_YEAR));
System.out.println(" WEEK_OF_YEAR : " + c.get(Calendar.WEEK_OF_YEAR));
System.out.println(" WEEK_OF_MONTH : " + c.get(Calendar.WEEK_OF_MONTH));
System.out.println(" DAY_OF_WEEK_IN_MONTH : " + c.get(Calendar.DAY_OF_WEEK_IN_MONTH));
System.out.println(" HOUR : " + c.get(Calendar.HOUR));
System.out.println(" AM_PM : " + c.get(Calendar.AM_PM));
System.out.println(" HOUR_OF_DAY (24-hour): " + c.get(Calendar.HOUR_OF_DAY));
System.out.println(" MINUTE : " + c.get(Calendar.MINUTE));
System.out.println(" SECOND : " + c.get(Calendar.SECOND));
System.out.println();*/ -
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 -
BIP eBusiness Suite Dates - How to include the last day of the month?
How can I get my report to include the last day of the month 'without' forcing my users to enter the non-intuitive first of the next month as a parm?
I have a report that will generally be run for a month but can be run for any pair of dates representing the first and last date to be included in the report.
When we pass the dates from Oracle Apps to the report it is truncating the date to midnight. This results in the last date entered 'NOT' being included in the report as the second date is marked as "midnight". When I attempt to simply add "=1" to the end date it fails due to formatting issues in apps (only). I have gotten this to work on our Enterprise edition server that we use for testing (only) but it fails in our apps environment.
In APPs we input the date in the format "01-AUG-2007", and this is how it shows in the parm line before the report is submitted as well as in the "View Details" after the report is executed: http://home.swbell.net/grog1//work/req_details_5607586.jpg
However it is odd in that we in the "View Log" entry it shows the date formatted as "2007/08/01 00:00:00": http://home.swbell.net/grog1/work/view_log_5607586.jpg
Even odder is that under diagnostics, "View XML" the date is formatted third way as: "2007/08/01 00:00:00.0" (note it now includes tenths of a second): http://home.swbell.net/grog1/work/view_xml_5607586.jpg
This of course makes it difficult to perform conversions and calculations on the date in the SQL.
Is APPs doing some sort of 'timestamp' conversion?
How can I get my report to include the last day of the month 'without' forcing my users to enter the non-intuitive first of the next month as a parm?
Any feedback is appreciated,
ScottNo. The problem/error occurs long before the data is formatted into xml for presentation to the format template.
The error occurs in the SQL in the 'data' template when I attempt to add a day to the date. It either does not like the implicit conversion with the "+1" and then the use of the "between" with another date or if I attempt to manually convert it has problems with the format mask.
Scott
Maybe you are looking for
-
Firefox 6.0 is not Displaying Symbols Correctly
Okay, ever since I updated to Firefox 6.0, it has not been displaying symbols correctly. It '''doesn't''' matter what site I'm on (I just used my twitter account as an example), as I'm having the same issue everywhere. Example on Firefox: http://i51.
-
How to find out who deleted the standard table enteries
Hi, Somebody has deleted entire KNA1 in one of our systems. Is there any way to find out who deleted the entries? Thanks & Regards, Kumaran Duraiswamy.
-
my customer is asking for a report sales region wise. i have taken as org units like sales office for all their sales offices and sales group for their sales persons, now how can i configure sales region ie., north ease west south, to take a standard
-
Hello i want to create new page format in sap script can any body guide to crate this & how to assign this thnks in advance
-
Hi folks, I would like to achieve the following functionality (in order) 1. Query DB 2. Parse results returned into CSV format (perhaps, in a stringbuffer or file) 3. Return the CSV file or string to the client 4. Display a pop up window to the user