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 K
Here 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
Similar Messages
-
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 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 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 -
Function to get the last day of the current month
Hi friends
Now I need to know a function to get the last day of a month. I had between my notes that function but I do not find it and I think you can give the answer faster.
Thanks
Joel Pérez
DBA OracleI know emoticons are a bit naff but in the absence of a UBB markup to indicate humourous intent they do serve to indicate a joke. This is useful in a purely verbal domain like these forums, especially given that many participants don't have English as their first lanaguage and so often miss the wordplay.
Cheers, APC -
Get the last date of a given date...
Hello experts,
How do I get the last date of a given date? for example:
20060615 "June 15,2006
So I want to get the last date of june so that will be
20060630
But I want to make it this way:
06/30/2006 because I will use it in my where clause.
Again, thanks a lot guys and take care!The date format should be in 'YYYYMMDD'
data : v_last_day like sy-datum,
v_in_date like sy-datum.
v_in_date = '20050109'.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = v_in_date
IMPORTING
LAST_DAY_OF_MONTH = v_last_day
* 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.
write : / v_last_day.
Cheers
VJ -
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 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 error for while loop?
How to get the last error for while loop? I just want transfer the last error for while loop, but the program use the shift register shift all error every cycle.
What do you mean by "get" and "transfer"?
If the shift register is not what you want, use a plan tunnel instead.
Typically, programmers are interested in the first, not last, error.
Can you show us your code so we have a better idea what you are trying to?
LabVIEW Champion . Do more with less code and in less time . -
Object date - how to get the last day of the month?
hi all,
I have a date object in which I would like to get the last day of the month. any idea?
eg AUG=31
Feb = 28 (depends if a leap year)
thanksUse java.util.Calendar
Add 1 month to the day.
Set the day of month to be 1.
Subtract 1 day.
Now you are on the last day of the month you wanted. -
C Programming: How can we get the filesystem name for a given file-path?
C Programming: How can we get the filesystem name for a given file-path?
Say I have a filepath=/mnt1/file1
Using some OS API like stat, can I get the Filesystem /mnt ?
Thanks in advance,
-VEnter the command up to the point of entering the file path and add a space, then drag the file into the terminal window. It will fill out the path.
If you need to go further into the contents of the Application package, you can continue with /Contents...
Another way is to start typing and then hit Tab to auto-complete. It will stop where it can't determine the next letter.
So, type /App tab and it will fill in /Applications. Type a / and start with the name of the app, then tab and it should complete. Continue till you have the correct path.
Spaces will be replaced with \<space>, so, App Store would end up as /Applications/App\ Store.app -
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 -
I need to get the current assignee for a given request using SOA's java api
I'm developing a spring app that interfaces with Oracle SOA suite and executes the actions such as approving requests using the api. I need to get the current assignee for each SOA Task this is dispalyed in the OIM console so it is getting it from somewhere. I tried getApprovers in the ITaskService api but this returns an empty list
I have checked it once again and there indeed are links for ALUI components for Solaris on SPARC at edelivery.oracle.com. (Officially ALUI supports Solaris on SPARC only)
If you have looked at Solaris x86, then you must not have found them. Please make sure that you are selecting the righ platform. Also, make sure that you click on the Aqualogic media pack so as to get the lists of the components included in it. (Point to Note: You need to go to the next level)
For whichever component you are not able to find, try looking for it in the Metalink (My Oracle Support) if you have a support contract. -
When I tried to import from my camera, the last day did not import, I keep retrying, but will not import. Could it have anything to do with the date Feb 29, 2012 as it was Leap Year?
OK Texas, so nothing strange with the calendar (unless you folk have seceded since the last time I checked the news )
Image Capture is an Apple App that comes with the OS. Allows you to do a bunch of things. Import pictures from your camera is one. Open the app with your camera connected. If you have Aperture set to open when the camera is connected just close Aperture and then open Image Capture.
You'll see the camera and it should show you the images on the camera card. See if the images from the 29th show up.
post the results.
regards
Maybe you are looking for
-
Can I access an import source file in CRM?
We've had a user export and re-import some data a few weeks back that's caused a bit of a problem on our CRM 2013 system which has only just come to light (audit histories now refuse to load). I'd like to see the source file that was imported so that
-
Good morning, I have problems with pdf link in Safari. Tapping on them they don't work. Thanks for the support. Danilo
-
Downloaded files will not move or allow to be edited?
Hi, I hope this is the correct place to ask this question. I currently have two hard drives, a HDD and SSD with HDD as the windows install/main drive. When I download files from google chrome, they go straight into my SSD in a 'downloads' folder. A
-
I have configured a JCA DB Adapter in OSB with a custom SQL query which is INSERT INTO "SYSTEM"."LOG_DETAIL" (LOG_ID, LOG_MESSAGE) VALUES (#logID, #logMessage) I created a business service (using WSDL of the DB Adapter). I am calling this business se
-
If it is possibal to downgrade iOS 8.0.2 to iOS 7.1.2?
BBcz there I s problem in iOS 8.0.2 network n connectivity