Sql to get the Monday of every IW week in a year!
Hi There!
This is an SOS :) I had to get a query to give me all the Mondays of a IW week in a year. I think as per the IW weeks there are around 52.1 weeks in a year. So basically, I want the starting Monday of every week. I would then store those values in a variable and use them in APEX as column headers. Online I saw some samples not related with this, but where looping was done using the all_objects. Not sure if that is the right approach.
The problem is since this is not stored in any table, how can I loop like 52/53 times such that the output shows all the Mondays (date format) for a given year. Basically, the output would be 52/53 rows with a date(monday of the week).
Please help!
thanks,
Sun
Edited by: ryansun on Jun 28, 2012 11:09 PM
Would this be something you are looking for?
SQL> variable yr number
SQL> exec :yr := 2015
SQL> with dates as (
2 select to_date('0101'||:yr,'ddmmyyyy')-4+level da
3 from dual
4 connect by level < 373
5 )
6 select :yr iyyy, to_char(da,'IW') iw, da monday
7 from dates
8 where to_char(da,'dyiyyy', 'nls_date_language=american')='mon'||:yr
9 ;
IYYY IW MONDAY
2015 01 29-12-2014
2015 02 05-01-2015
2015 03 12-01-2015
2015 04 19-01-2015
2015 05 26-01-2015
2015 06 02-02-2015
2015 07 09-02-2015
2015 08 16-02-2015
2015 09 23-02-2015
2015 10 02-03-2015
2015 11 09-03-2015
2015 12 16-03-2015
2015 13 23-03-2015
2015 14 30-03-2015
2015 15 06-04-2015
2015 16 13-04-2015
2015 17 20-04-2015
2015 18 27-04-2015
2015 19 04-05-2015
2015 20 11-05-2015
2015 21 18-05-2015
2015 22 25-05-2015
2015 23 01-06-2015
2015 24 08-06-2015
2015 25 15-06-2015
2015 26 22-06-2015
2015 27 29-06-2015
2015 28 06-07-2015
2015 29 13-07-2015
2015 30 20-07-2015
2015 31 27-07-2015
2015 32 03-08-2015
2015 33 10-08-2015
2015 34 17-08-2015
2015 35 24-08-2015
2015 36 31-08-2015
2015 37 07-09-2015
2015 38 14-09-2015
2015 39 21-09-2015
2015 40 28-09-2015
2015 41 05-10-2015
2015 42 12-10-2015
2015 43 19-10-2015
2015 44 26-10-2015
2015 45 02-11-2015
2015 46 09-11-2015
2015 47 16-11-2015
2015 48 23-11-2015
2015 49 30-11-2015
2015 50 07-12-2015
2015 51 14-12-2015
2015 52 21-12-2015
2015 53 28-12-2015
53 rows selected.
Similar Messages
-
Dear all;
I am using trunc(add_months(sysdate, 1 * -12)), which get me 05/18/2010 however what I would like to do is bascially if that date doesnt fall on a monday then get the monday associated with it in that period, so in this case the monday associated with it is 05/17/2010. how do I modify that to get what i want.
Edited by: user13328581 on May 18, 2011 8:36 AMSQL> select trunc(add_months(sysdate, 1 * -12),'IW') from dual
2 /
TRUNC(ADD
17-MAY-10
SQL> OR:
SQL> select next_day(trunc(add_months(sysdate, 1 * -12)) - 7,'monday') from dual
2 /
NEXT_DAY(
17-MAY-10
SQL> SY. -
Generating SQL in a PL/SQL progam ( getting the values of a value)
Hi,
We're using Oracle 11.1.
I want to generate sql to do the following
something like
fld_pos(i) = 'MPI';Where fld_pos is part of a varray.
The basic procedire is below.
PROCEDURE get_oldest_mpi (
pin_fld0 VARCHAR2
, pin_fld1 VARCHAR2
, pin_fld2 VARCHAR2
, pin_fld3 VARCHAR2
, pin_fld4 VARCHAR2
, pin_fld5 VARCHAR2
, pin_fld6 VARCHAR2
, pin_fld7 VARCHAR2
, pin_fld8 VARCHAR2
, pin_fld9 VARCHAR2
, pin_fld10 VARCHAR2
, pin_fld11 VARCHAR2
, pin_fld12 VARCHAR2
, pin_fld13 VARCHAR2
IS
TYPE fld IS VARRAY(14) OF VARCHAR2(50);
fld_pos fld;
v_sql_stmt VARCHAR2(1000);
mpi_pos number;
BEGIN
--load the pin_fld vars into an array so they can be processed in a loop
FOR i IN 1..fld_pos.COUNT
LOOP
fld_pos(i) := 'pin_fld'||i;
END LOOP;
--see if the variable pin_fld'x' = the word 'MPI'
FOR i IN 1..fld_pos.COUNT
LOOP
IF fld_pos(i) = 'MPI' then -- I know this statement is wrong. This is where I need help.
mpi_pos :=i;
END IF;
END LOOP;
.I know that 'fld_pos(i)' equals 'pin_fld||i .
So how do I get to the value in the value for this? How can generate the SQL to get the expression I need?
Thanks,Hi,
It's still an awkward procedure, but
CREATE OR REPLACE PROCEDURE get_oldest_mpi (
pin_fld0 VARCHAR2,
pin_fld1 VARCHAR2,
pin_fld2 VARCHAR2,
pin_fld3 VARCHAR2,
pin_fld4 VARCHAR2,
pin_fld5 VARCHAR2,
pin_fld6 VARCHAR2,
pin_fld7 VARCHAR2,
pin_fld8 VARCHAR2,
pin_fld9 VARCHAR2,
pin_fld10 VARCHAR2,
pin_fld11 VARCHAR2,
pin_fld12 VARCHAR2,
pin_fld13 VARCHAR2
) IS
TYPE fld IS VARRAY (14) OF VARCHAR2 (50);
fld_pos fld
:= fld (pin_fld0,
pin_fld1,
pin_fld2,
pin_fld3,
pin_fld4,
pin_fld5,
pin_fld6,
pin_fld7,
pin_fld8,
pin_fld9,
pin_fld10,
pin_fld11,
pin_fld12,
pin_fld13
v_sql_stmt VARCHAR2 (1000);
mpi_pos NUMBER;
BEGIN
--see if the variable pin_fld'x' = the word 'MPI'
FOR i IN 1 .. fld_pos.COUNT LOOP
IF fld_pos (i) = 'MPI' THEN
mpi_pos := i;
END IF;
END LOOP;
END;
/Regards
Peter -
I keep getting the following message every time i plug in my Iphone3gs to Itunes on my windows vista computer
Itunes was unable to load data class information from sync services. reconnect or try again later.
any suggestions pls
MarioThe article says that I should upgrade to the latest iTunes. I am on the latest iTunes version.
If you could read just a tiny little bit further, under the "Additional Information" section immediately after that, it says:
If you are still experiencing this issue when syncing, or have not installed Xcode 4 and get this alert:
Follow the troubleshooting steps in Mac OS X v10.5, v10.6: Resetting the SyncServices folder.
If the issue is still unresolved, follow steps in Sync Services: Advanced troubleshooting for contact and calendar syncing.
Have you tried those measures? -
when i click on my external hard drive the screen goes dark and a msg pops up saying i have to shut down my computer by holding the power button and then restart it. when i do that i get the same result every time. it worked perfectly last night..
These instructions must be carried out as an administrator. If you have only one user account, you are the administrator.
Launch the Console application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
Ifou don't see any reports listed, but you know there was a panic, you may have chosen Diagnostic and Usage Messages from the log list. Choose DIAGNOSTIC AND USAGE INFORMATION instead.
In the Console window, select
DIAGNOSTIC AND USAGE INFORMATION ▹ System Diagnostic Reports
(not Diagnostic and Usage Messages) from the log list on the left. If you don't see that list, select
View ▹ Show Log List
from the menu bar.
There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points down. You'll see a list of reports. A panic report has a name that begins with "Kernel" and ends in ".panic". Select the most recent one. The contents of the report will appear on the right. Use copy and paste to post the entire contents—the text, not a screenshot.
If you don't see any reports listed, but you know there was a panic, you may have chosen Diagnostic and Usage Messages from the log list. Choose DIAGNOSTIC AND USAGE INFORMATION instead.
In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.)
Please don’t post other kinds of diagnostic report.
I know the report is long, maybe several hundred lines. Please post all of it anyway. -
Do you get the Installation indicator every time you Restart or Start Up your computer?
Do you get the Installation indicator every time you Restart or Start Up your computer? On all my computers upgraded to 10.10, I get the Installation "thermometer" indicator every time I Restart or Start Up my computers. In Verbose mode, I see a bash command that is looking for the Installation image to finish its clean up. Does anyone else have this problem? Is the Installation indicator the new "normal" start up and restart screen for 10.10?
If you are referring to the progress indicator that appears every startup, that is normal. It has replaced the old spinning gear. There's nothing wrong.
-
I get the following message every time I open my contacts on my iphone or iPad : "Password Incorrect. Enter the password for the Exchange account "Exchange"". If I enter my password, it does not accept it. I don't even know what this means.
http://support.apple.com/kb/ht1212
-
Get the Current Quarter and Current Week from date
Hi,
I want to get the Current quarter and Current week from a given date, which function modules should i use?
I tried using function module - 'HR_99S_GET_QUARTER' for getting the quarter but it is throwing an error while loading data. Moreover it doesnt exist in BI7.
Similarly for current week.
Please help. Sample code snippets would be appreciated.
Thanks
JayaYou can use FORM time_conversion wich is the one used by standard in Update Rules:
You can select whether convert 0CALDAY to 0CALWEEK or whatever infobject formats you prefer...
perform time_conversion
using '0CALDAY'
'0CALMONTH'
p_input_date
l_fscvtval
changing RESULT
c_t_idocstate
c_subrc
c_abort.
if c_subrc <> 0 or c_abort <> 0.
exit.
endif.
form time_conversion
using i_timnm_from type rsiobjnm
i_timnm_to type rsiobjnm
i_timvl
i_fiscvarnt type t009b-periv
changing e_timvl
c_t_idocstate type rsarr_t_idocstate
c_subrc like sy-subrc
c_abort like sy-subrc. "#EC *
data: l_timvl type rsd_chavl,
l_result type rsd_chavl.
IF i_timvl CO ' 0'.
CLEAR e_timvl.
EXIT.
ENDIF.
l_timvl = i_timvl.
CALL FUNCTION 'RST_TOBJ_TO_DERIVED_TOBJ'
EXPORTING
i_timnm_from = i_timnm_from
i_timnm_to = i_timnm_to
i_timvl = l_timvl
I_FISCVARNT = i_fiscvarnt
I_BUFFER = rs_c_true
IMPORTING
E_TIMVL = l_result
EXCEPTIONS
INCOMPATIBLE_TOBJS = 1
NO_INPUT_VALUE = 2
FISCVARNT_MISSING = 3
INPUT_NOT_NUMERIC = 4
WRONG_DATE = 5
WRONG_FISCPER = 6
X_MESSAGE = 7
OTHERS = 8
e_timvl = l_result.
ENDFORM. "TIME_CONVERSION -
How do i get the date when enter a week number
Hi, can anyone tell me how do i get the date when enter a week number??
let say, i enter week number 4 and year 2008
result=26-01-2008
thanks..import java.util.Calendar;
public class testCalendar {
public static void main(String args[]){
int year=2008;
int week =5;
Calendar now=Calendar.getInstance();
now.set(Calendar.YEAR,year);
now.set(Calendar.WEEK_OF_YEAR,week);
System.out.println(now.getTime());
hai, anyone know why i can't get the result:27-01-2008
i always get two day later. That is 29-01-2008
no wonder how i change the week number and year.
for example: week=7, year=2007
expected result:11-02-2007
but the result is 13-02-2007
thanks..
Edited by: Angel_Wei on Sep 1, 2008 11:58 PM -
Is it possible to get the license of photoshop and lightroom after 4 years of subscription?
Is it possible to get the license of photoshop and lightroom after 4 years of subscription?
No, it is not. Perpetual licenses are not available.
(If the reward for a few years subscription was a permanent license, soon Adobe's entire business model would collapse, because money from subscriptions would stop). -
Did anyone else get the free 1 gb of data for 2 years when preordering the iphone6?
Did anyone else get the free 1 gb of data for 2 years when preordering the iphone6?
I am on More Everything. Edge is actually not a plan, but an add on for financing a phone while still actually being on the More Everything Plan. Regardless, I am not using Edge.
-
Bom explosion how to get the least level every stufe = 1
material number : 2t67363633
following is the bom of that materials
the below ouput is i got it from cs12
.1 010 6631030681
..2 010 INL025000650
..2 020 IN6631030681
.1 020 6650002622
..2 010 950002621GV
.1 030 6682500491
.1 040 712758079
but in cs13 the following output i got only the following for the same materials
.1 010 6631030681
..2 010 INL025000650 -
i got this
..2 020 IN6631030681 -
i got this
.1 020 6650002622
..2 010 950002621GV -
i got this
.1 030 6682500491 -
i got this
.1 040 712758079 -
i got this
requirement is take the least items in every level1 items
supouse if the level1 item doesnt have any subitems ,we ll take this one also
following is the detiails for the senario,using this to restrict and how to get the cs13 above output
level fld2 fld3 fld4 fld5 fld6 fld7 componentname
.1 0000001 00000097 001 00002 0001 010 6631030681 -
..2 0000001 00000093 002 00002 0001 010 inl025000650
..2 0000002 00000093 002 00004 0002 020 in6631030681-1560
.1 0000002 00000097 001 00004 0002 020 6650002622
..2 0000001 00000095 002 00002 0001 010 950002621gv
.1 0000003 00000097 001 00006 0003 030 6682500491
<b> .1 0000004 00000097 001 00008 0004 040 712758079</b>
i here attached my code for ur review
i got the output without the last leve i bold it. is there any logic to solve the problem
TABLES : MAST.
DATA: BEGIN OF ISTPO OCCURS 1000.
INCLUDE STRUCTURE STPOX.
DATA: END OF ISTPO.
DATA: W_TOPMAT LIKE CSTMAT.
SELECT-OPTIONS : P_MATNR FOR MAST-MATNR.
PARAMETERS : P_WERKS TYPE MAST-WERKS.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MAST-MATNR,
WERKS LIKE MAST-WERKS,
END OF ITAB.
DATA: IT_STB LIKE ISTPO OCCURS 0 WITH HEADER LINE.
data : istpofinal like istpo occurs 0 with header line.
data : istpotemp like istpo occurs 0 with header line.
START-OF-SELECTION.
CLEAR ISTPO. REFRESH ISTPO.
SELECT MATNR WERKS FROM MAST INTO TABLE ITAB
WHERE MATNR IN P_MATNR AND WERKS = P_WERKS.
LOOP AT ITAB.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
CAPID = 'PP01'
MEHRS = 'X'
MMAPS = ' '
MDMPS = ' '
BREMS = 'X'
DATUV = SY-DATUM
MTNRV = ITAB-MATNR
WERKS = P_WERKS
EMENG = '1'
STKKZ = ' '
FBSTP = ' '
FTREL = ' '
IMPORTING
TOPMAT = W_TOPMAT
TABLES
STB = ISTPO
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
OTHERS = 8.
IF SY-SUBRC = 0.
WRITE:/ 'MaterialNumber' ,21 'Description'.
SKIP 1.
endif.
WRITE: / W_TOPMAT-MATNR UNDER TEXT-H00 COLOR COL_HEADING,
W_TOPMAT-MAKTX UNDER TEXT-H01 COLOR COL_HEADING.
data : ttabix like sy-tabix,
tstufe like stpox-stufe.
data : len type i.
istpotemp[] = istpo[].
describe table istpotemp lines len.
LOOP AT ISTPO .
WRITE :/ ISTPO-STPOZ,
ISTPO-STLKN,
ISTPO-POSNR,
ISTPO-IDNRK,
ISTPO-OJTXP,
ISTPO-MENGE,
ISTPO-MEINS.
if sy-tabix = len.
move-corresponding istpo to istpofinal.
append istpofinal.
exit.
endif.
ttabix = sy-tabix - 1 .
if tstufe ge istpo-stufe.
read table istpotemp index ttabix.
move-corresponding istpotemp to istpofinal.
append istpofinal.
endif.
tstufe = istpo-stufe.
ENDLOOP.
*endif.
endloop.
skip 3.
loop at istpofinal.
WRITE :/ ISTPOFINAL-STPOZ,
ISTPOFINAL-STLKN,
ISTPOFINAL-POSNR,
ISTPOFINAL-IDNRK,
ISTPOFINAL-OJTXP,
ISTPOFINAL-MENGE,
ISTPOFINAL-MEINS.
endloop.Hi Shiba,
We got the required list,
But while using select-option to view multiple values the list of datas in the ISTPOFINAL gets displayed like the given below.
example
Material1
.........Component 1
.........Component 2
Material 2
.........Component 1......... From Material 1
.........Component 2......... From Material 1
.........Component 3
.........Component 4
Material 3
.........Component 1......... From Material 1
.........Component 2......... From Material 1
.........Component 3......... From Material 2
.........Component 4......... From Material 2
.........Component 5
.........Component 6
Like this it goes on for the entire list at the tie of displaying the ISTPOFINAL.
We tried evn by deleting the adjacent duplicate values still it gets displayed.
is there any problm with the loop or is it the problm with the ending of the loop.
Pls suggest us.
LOOP AT ITAB.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
CAPID = 'PP01'
MEHRS = 'X'
MMAPS = ' '
MDMPS = ' '
BREMS = 'X'
DATUV = SY-DATUM
MTNRV = ITAB-MATNR
WERKS = P_WERKS
EMENG = '1'
STKKZ = ' '
FBSTP = ' '
FTREL = ' '
IMPORTING
TOPMAT = W_TOPMAT
TABLES
STB = ISTPO
MATCAT = MATCAT
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
OTHERS = 8.
WRITE: / W_TOPMAT-MATNR UNDER TEXT-H00 COLOR COL_HEADING,
W_TOPMAT-MAKTX UNDER TEXT-H01 COLOR COL_HEADING.
data : ttabix like sy-tabix,
tstufe like stpox-stufe.
data : len type i.
istpotemp[] = istpo[].
describe table istpotemp lines len.
loop at istpo.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
CAPID = 'PP01'
MEHRS = 'X'
MMAPS = ' '
MDMPS = ' '
BREMS = 'X'
DATUV = SY-DATUM
MTNRV = ISTPO-IDNRK
WERKS = P_WERKS
EMENG = '1'
STKKZ = ' '
FBSTP = ' '
FTREL = ' '
IMPORTING
TOPMAT = W_TOPMAT
TABLES
STB = ISTPOTEMP
MATCAT = MATCAT
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
OTHERS = 8.
if sy-subrc ne 0.
move-corresponding istpo to istpofinal.
append istpofinal.
clear: istpo, istpofinal.
else.
continue.
clear: istpo, istpofinal.
endif.
*break-point.
delete adjacent duplicates from istpofinal.
endloop.
loop at istpofinal.
WRITE :/ ISTPOFINAL-STPOZ,
ISTPOFINAL-STLKN,
ISTPOFINAL-POSNR,
ISTPOFINAL-IDNRK,
ISTPOFINAL-OJTXP,
ISTPOFINAL-MENGE,
ISTPOFINAL-MEINS.
clear: istpofinal.
endloop.
endloop. -
I have been getting the tritone sound at 2 :17 pm every day for a while now with no message or notification to back it up , I think this has been a long term problem since 2009 according to your past discussions , so has anyone solved this problem yet? 1phone 4s system ios 6.1.3. Driving me crazy diving for the phone and seeing a blank screen , feel like someone some where is saying 'got ya' and laughing their butt off every time.
I have been getting the tritone sound at 2 :17 pm every day for a while now with no message or notification to back it up , I think this has been a long term problem since 2009 according to your past discussions , so has anyone solved this problem yet? 1phone 4s system ios 6.1.3. Driving me crazy diving for the phone and seeing a blank screen , feel like someone some where is saying 'got ya' and laughing their butt off every time.
-
Can a pl sql cartridge get the client certificate through ssl in OAS
I am In a web publishing system project, I use SSL and client certificate to verify the user, the environment is OAS4.0.6 and Oracle 8i, and I use PL SQL cartridge to proceed the http request , Now the problem is how can I get the client certificate infomation in my pl sql scripts, I do not know where should i post this problem, So I post it here, If you have any experience in using SSL of OAS, pls help me!
tsailiang
[email protected]
thank you very much!Sorry wrong forum.....
This forum is for the Internet File Server (ifs) not the oracle application server (oas), sometimes known as iAS or Oracle9i Applicaiton Server.
null -
When I click on Yahoo Bookmark Icon & click on Save this page,
I get the normal screen Save To My Bookmarks, etc. I fill out as
normally & click save. That is when I receive blue screen with above message. Frustrating because it lets me go through the process but then will not save. Is this a cookie or privacy issue??At the top of yahoo bookmarks there is a message:
To Yahoo! Bookmarks users:
Yahoo! Bookmarks is transitioning and will be exclusively available via Yahoo! Toolbar. During this transition, you will be able to access your bookmarks in read-only mode.We expect the transition to be fully complete by October 20, 2011, after which you will have access to your bookmarks with the ability to add/ edit/ delete bookmarks.
Please download Yahoo! Toolbar for a full bookmarks service. We sincerely apologize for any inconvenience during this period.
But the toolbar dosn't work either, even after it is updated, so we may just have to wait.
Hope this helps :)
Maybe you are looking for
-
plis help me with this, is like my pc is not recognize the iphone like an usual connection network, always ask me the type of connection network like the first time i plug in my iphone i see this since the new iphone software update to ios 5 sorry
-
BO DI for extracting data from legacy system to SAP BW 7.0
Hi, Has anyone worked on scenario where BO Data Integrator is being used as ETL tool for extracting data from legacy systems to SAP BW 7.0 ? Please share your experience on such a landscpae or related documents any of you had come across. Regards, Pr
-
Thunderbolt-Firewire adapter not good for networking?!
Hi folks, I have been successfully running a mini Firewire network between my old iMac and my MacPro for several years just using a FW 800 to FW 400 cable. NOW I bought the new iMac with Thunderbolt and the Apple Thunderbolt to Firewire adapter. Unfo
-
How to display the request date in query
Hi, I want to display the No. of request ID and request date in the query, but how could I get the request date? Can anyone give me some suggestion? Thanks Huaiyuan
-
What happened to the help feature in CS5
Prior Photoshop versions had a help feature that brought up a document where topics could be easily located in an index. In CS5 this help functionality no longer exists, or I can not find it. Instead there is some new help document that contains no i