Find dates between 2 dates given
HelloI want to write pl/sql block that will give me the dates between 2 dates that I entered. Are there any oracle in built function that does. I use version oracle 11g rel2.
We know not what you want, but it looks like:
SQL> select &start_date + level - 1 dt
2 from dual
3 connect by &start_date + level - 1 <= &end_date
4 /
Enter value for start_date: date '2012-08-01'
old 1: select &start_date + level - 1 dt
new 1: select date '2012-08-01' + level - 1 dt
Enter value for start_date: date '2012-08-01'
Enter value for end_date: date '2012-08-31'
old 3: connect by &start_date + level - 1 <= &end_date
new 3: connect by date '2012-08-01' + level - 1 <= date '2012-08-31'
DT
---------
01-AUG-12
02-AUG-12
03-AUG-12
04-AUG-12
05-AUG-12
06-AUG-12
07-AUG-12
08-AUG-12
09-AUG-12
10-AUG-12
11-AUG-12
DT
---------
12-AUG-12
13-AUG-12
14-AUG-12
15-AUG-12
16-AUG-12
17-AUG-12
18-AUG-12
19-AUG-12
20-AUG-12
21-AUG-12
22-AUG-12
DT
---------
23-AUG-12
24-AUG-12
25-AUG-12
26-AUG-12
27-AUG-12
28-AUG-12
29-AUG-12
30-AUG-12
31-AUG-12
31 rows selected.
SQL>
SY.
Tags: Database
Similar Questions
-
Hi all
I need the days between two dates given.
Select to_date('25-mar-2014','dd-mon-yyyy') start_date, end_date to_date('30-mar-2014','dd-mon-yyyy')
of the double
Desired output:
25
26
27
28
29
30
Thanks in advance.
Kind regards
Afzal.
Select the level - 1 desired_output + to_number (to_char (start_date, 'dd'))
of (to_date('25-mar-2014','dd-mon-yyyy') select start_date, end_date to_date('30-mar-2014','dd-mon-yyyy'))
of the double
)
connect by level<= end_date="" -="" start_date="" +="">= >
DESIRED_OUTPUT 25 26 27 28 29 30 Concerning
Etbin
-
y at - it sites to find dates and the drivers, windows 7
is there free online sites to find dates and pilots.
running windows 7
Thank you
The best place is the manufacturer of your computer - try first. They should provide free drivers for the supported versions of Windows.
You can also try the individual hardware components manufacturers. For example, NVidia, AMD and Intel for graphics cards. In general, this should be free.
I would recommend avoiding utilities part 3rd pilot and Web sites, especially ones that cost money. It is usually unnecessary to use. He peut also have concerns quality and/or safety with some of them.
Windows Update can also provide drivers for some hardware. There is no cost and no real security issues by using this method, but drivers may be generic and lacking some features.
I prefer to install drivers when I want to and do it manually. It keeps me in control of the process and means if there is a problem it is easier to track what if its done to another more "in bulk".
-
Can't find "Data export" option under 'Tools' in 'SQL Developer?
Can't find "Data export" option under 'Tools' in 'SQL Developer?
How can I solve this problem?
Thank you
SivaHello
on the Tools menu, you will see "Unloading of database" option. That's what you're looking for (the 'Export' label has been changed to "Unload".
I hope this helps.
R / Zaf -
find data files belong to the backup piece
Hi all
DB 10.2.03.0
Y at - it notice, that we can use to find data files belong to the backup piece. We can query the handle in order to find the name of the element.
Hare krishnaHi Amit,
Y at - it notice, that we can use to find data files belong to the backup piece.
In fact, you have to join the three points of view in a sql against the target:
Select p.handle, d.name
Of
v$ element_sauvegarde p,.
v$ backup_datafile bd.
v$ datafile d
where p.handle = "& manage.
and bd.set_stamp = p.set_stamp
and bd.set_count = p.set_count
and bd.file # d.file = #.
/
Rgds,
Tycho -
How to find date of creating index?
How to find date of creating index?You query all_obejcts and you will find last_ddl_time when is - it has changed...
-
In the latest version of cards, there is not apparent until you find directions between two places when or is your current position. In earlier versions, we enter in two places of departure and destination. In the new version, you enter your destination into a search window, but there is no place to enter a starting location. The application assumes that your current place of residence is always your place of departure. It is a remarkable oversight by designers. Am I missing something?
If you go to maps, you can search for a location. Once you find the place, press the route button. It is from your current location, but if you type on my position, next: you can change the location that you want the management of.
-
Hi all
I use SOASuite 11 g. Using XSLT, I want to find some dates between 2 dates
For example, if I input 01-02-2016 and 2016-02-07
The XSLT must return
2016-02-01,.
2016-02-02,.
2016 02-03,
2016 02-04,
2016 02-05,
2016 02-06,
2016 02-07
can someone suggest me how to build this logic in the xslt file?
Thank you
(1) fn:days - of-life feature gives you the difference in days between two dates.
(2) use the value above in the foreach loop and then create a counter variable and map it to element position().
(3) now use this counter variable in the Sub method within the loop for.
xs:date(fromdate) + xs:dayTimeDuration(concat('P',$counter,'D'))
(4) you can now print this value (or) copy it to a repetitive Xml structure element. When copying, you can use the $counter as an index for the repetitive element of the target.
Now if you want including and to the dates too, then add 1 to the output in step 1 and step 3 use $counter - 1 in xs:dayTimeDuration.
It will be useful.
-
find moments between 17:00 and 07:00 (inclusive) of a date field time
I'm trying to find all appointments for patients scheduled between 17:00 and 07:00. That's any day. The appt_date field is a date field.
I tried: AND TO_CHAR(APPT_DATE,'HH24:MI:SS AM') > = 17:00:00 ' AND TO_CHAR(APPT_DATE,'HH24:MI:SS') < =' 07:00:00 '
and that leaves patients with visits at 07:00.
I tried AND TO_CHAR (APPT_DATE, 'HH24') between '7' and '17' - knowing he would also understand a lot, but still it does not work.
Any recommendations?
Published by: br * on August 31, 2011 07:29Hello
These conditions are mutually exclusive.
If the appointment is after 17:00, then it will not be before 07:00.
If the appointment is before 07:00, then it will not be after 17:00.
You need to use OR not, AND to connect these two conditions, like this:AND ( TO_CHAR (APPT_DATE, 'HH24:MI:SS') >='17:00:00' OR TO_CHAR (APPT_DATE, 'HH24:MI:SS') <='07:00:00' )
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using. -
Find days between the dates expressed in days.
Hi, I have a table with a structure similar to the following:
LP1 TIME_EQ P_DAY LP2 17.2 0
MONDAY 16.8 0.25
TUESDAY 17.03 .5 THURSDAY 17 .75 FRIDAY 17.4 1 FRIDAY 16.9 .25 SATURDAY 17.1 .25 SATURDAY 17 .5 SUNDAY Now I have two variables dates D1 = October 10, 2013 (Thursday) and D2 = 13 October 2013 (Sunday).
How do I change my table such as only the lines covered between dates D1 and D2 are updated? In this case, the lines where the P_DAY (Thursday, Friday, Saturday, Sunday) I will use it for my slider, my query begins with this:
CURSOR LOAD_PROF is
SELECT LP1, TIME_EQ, P_DAY
DE LOAD_PROFILE_TEST
OÙ P_DAY in (? days between D1 and D2).
I hope you get my point. Thank you.
First impression is that your table design seems incorrect to me. Why just store DAY? Why not the whole date?
Says you can do this
Select lp1
time_eq
p_day
of load_profile_test
where p_day in)
Select to_char (start_date + (level 1), "fmDAY") day_
de)
Select to_date (October 10, 2013 ',' mon-dd-yyyy "") start_date
, to_date (13 October 2013 ',' mon-dd-yyyy "") end_date
of the double
)
connect
by level<= end_date="" -="" start_date ="" +="">= >
)
And finally the cursor? Try to do so in direct SQL. Do not loop through a cursor. If you share this part, we can give you best suggestion on the implementation of your real problem.
-
How to find days between two dates in days
Hi, I want to get the days between two dates, expressed in days, how can I do this? For example, I date i.e. 1 October 10, 2013 (Thursday) and 2 as October 13, 2013 (Sunday). How can I get a production of:
Thursday, Friday, Saturday and Sunday, which are the days between Oct. 10-13, 2013. I hope you understand my point. Thank you
You can try something like this
CURSOR LOAD_PROF is
SELECT load_prof1, v_time_profile_day
OF load_profile_test
WHERE profile_day IN (select TO_CHAR(:day1+level-1,'Day')
of the double
connect by level<>
);
Kind regards
S Pax
-
Logic to find particular weekdays after a given date, using SQL
Hello Experts,
Version: Oracle 11G
Could you please help me with logic to find a day of special week after a date in SQL
For example, I need to know the first Friday after today's date.
Thank you for your help.I hope that under query will be useful for you.
SELECT NEXT_DAY(SYSDATE,'FRIDAY') "NEXT DAY" FROM DUAL Output: NEXT DAY 2/24/2012 12:06:48 PM
-
Find data between certain values
Hello world
I need help with the script below.CREATE TABLE BILL_TBL ( "CUSTOMER_ID" NUMBER(18,0), "BILL_ID" NUMBER(18,0), "BILL_ISSUE_DATE" DATE, "BILL_DUE_DATE" DATE, "BILL_DUE_AMOUNT" NUMBER(20,5), );
The query must sort by customer_id, bill_issue_date desc as give below, that retrieves records in which the bill_due_amount is between group by CUSTOMER_ID 0Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,143787012,to_timestamp('12/09/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/10/2011','DD/MM/RRRR HH24:MI:SSXFF'),0); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,147279454,to_timestamp('12/10/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/11/2011','DD/MM/RRRR HH24:MI:SSXFF'),0); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,161587732,to_timestamp('12/02/2012','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/03/2012','DD/MM/RRRR HH24:MI:SSXFF'),2.05); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,150481573,to_timestamp('09/11/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('09/11/2011','DD/MM/RRRR HH24:MI:SSXFF'),0); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,153076866,to_timestamp('01/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('01/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),0); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,156547549,to_timestamp('30/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('30/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),0); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,150793135,to_timestamp('12/11/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),58.38); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,159764979,to_timestamp('24/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('24/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),0); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,154467859,to_timestamp('12/12/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),0); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,157241037,to_timestamp('05/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('05/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),0); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (3115166,158065763,to_timestamp('12/01/2012','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('12/02/2012','DD/MM/RRRR HH24:MI:SSXFF'),0); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (100,123456721,to_timestamp('13/05/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('13/06/2012','DD/MM/RRRR HH24:MI:SSXFF'),123.12); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (100,123456722,to_timestamp('13/03/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('13/04/2012','DD/MM/RRRR HH24:MI:SSXFF'),144.12); Insert into BILL_TBL (CUSTOMER_ID,BILL_ID,BILL_ISSUE_DATE,BILL_DUE_DATE,BILL_DUE_AMOUNT) values (100,123456723,to_timestamp('13/01/2011','DD/MM/RRRR HH24:MI:SSXFF'),to_timestamp('13/02/2012','DD/MM/RRRR HH24:MI:SSXFF'),4.12);
examples of data
Presents the expected resultsCUSTOMER_ID BILL_ID BILL_ISSUE_DATE BILL_DUE_DATE BILL_DUE_AMOUNT 100 123456721 13/05/2011 13/06/2011 123.12 100 123456722 13/03/2011 13/04/2011 144.12 100 123456723 13/01/2011 13/02/2011 4.12 3115166 161587732 12/02/2012 12/03/2012 2.05 3115166 159764979 24/01/2012 24/01/2012 0 3115166 158065763 12/01/2012 12/02/2012 0 3115166 157241037 05/01/2012 05/01/2012 0 3115166 156547549 30/12/2011 30/12/2011 0 3115166 154467859 12/12/2011 12/01/2012 0 3115166 153076866 01/12/2011 01/12/2011 0 3115166 150793135 12/11/2011 12/12/2011 58.38 3115166 150481573 09/11/2011 09/11/2011 0 3115166 147279454 12/10/2011 12/11/2011 0 3115166 143787012 12/09/2011 12/10/2011 0
Any help will be appreciated. Thanks in advanceCUSTOMER_ID BILL_ID BILL_ISSUE_DATE BILL_DUE_DATE BILL_DUE_AMOUNT 3115166 150793135 12/11/2011 12/12/2011 58.38
select CUSTOMER_ID, BILL_ID, BILL_ISSUE_DATE, BILL_DUE_DATE,BILL_DUE_AMOUNT from ( select CUSTOMER_ID, BILL_ID, BILL_ISSUE_DATE, BILL_DUE_DATE,BILL_DUE_AMOUNT, lag(BILL_DUE_AMOUNT) over(partition by CUSTOMER_ID order by BILL_ID desc) b, lead(BILL_DUE_AMOUNT) over(partition by CUSTOMER_ID order by BILL_ID desc) a from testdata) where a = 0 and b = 0 and nvl(BILL_DUE_AMOUNT,0) != 0
-
find data between specific times in a date range
HII all,.
I'm pretty new in PL/SQL so any help will be greatly appreciated. I'm trying to retrieve data from a set of tables. one of these tables has a field that is a timestamp in the format «dd/mm/yyyy hh24:mi:ss» field asked me to produce data for records that were created between 16:00 and 20:00 between 01/01/2010 and 31/08/2010. I can eat the date of issue, but the question of time is that I'm stuck.
your help would be appreciatedSELECT * FROM my_table WHERE col_date BETWEEN DATE '2010-01-01' AND DATE '2010-09-01' AND TO_NUMBER ( TO_CHAR ( col_date, 'HH24MI' )) BETWEEN 1600 AND 2000;
Now something difficult:
A DATE data type represents a specific time. It's something abstract. There's no format. It is in some cases stored internally, but we know not how (in fact, we know a little). Cannot directly display a DATE value - it is not a text, it is a point in time, it can be established on a calendar and a clock, but not on the screen. DATE FORMAT allows us to tell Oracle how we want it to be converted into a string and displayed. Do we want to day/month/year or year/day/month? Do we want a 24 hour clock 12-hour am/pm or? The same value, the same point in time can be displayed using different channels, produced using different DATE FORMATS. "Friday, September 17, 2010 13:15" is exactly the same point in time as "2010-09-17 13:15" - the only difference is the FORMAT. This allows us to perform several clever tricks with DATE data. Ok?
(If you do not specify a DATE format, and then there are the values by default for your session and for the database. But the principle remains the same: a point-in-time value is converted to a string using the DATE FORMAT). -
need help with query can find data back please help.
Hi guys I have a table such as
and I have a data as suchCREATE TABLE "FGL" ( "FGL_GRNT_CODE" VARCHAR2(60), "FGL_FUND_CODE" VARCHAR2(60), "FGL_ACCT_CODE" VARCHAR2(60), "FGL_ORGN_CODE" VARCHAR2(60), "FGL_PROG_CODE" VARCHAR2(60), "FGL_GRNT_YEAR" VARCHAR2(60), "FGL_PERIOD" VARCHAR2(60), "FGL_BUDGET" VARCHAR2(60) )
I need bascially to get the total of the budget column. However this is not as simple as it sounds good (at least not for the me.) totals carried forward to the new period. you will notice that you have a period column. Basically, what im is thatInsert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','1','400'); Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','1','100'); Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','0'); Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200'); Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','14','100'); Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','2','100'); Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7470','4730','02','10','2','200');
fgl_grant_year 10 1 period = account 7600 its $100 and $100 for the period 2, you see $ 100 more, it wants to not be added to this is the door on the balance. that is $100.
So im trying to write a query that basically does the following.
IM considering a period for the sake of this example let period 1 I get anything else. I find that the greates contributes dumpster year the amount for the period 14 (which corresponds to the total of the previous year) and add it to the amount of the current year. in this case period 1 grnt_year 11
the expected result is therefore $700
do not forget that I am not given a just a period of the year.240055 240055 7240 4730 02 10 14 200 240055 240055 7600 4730 02 10 14 100 240055 240055 7600 4730 02 11 1 400
any help you guys can give would be immensely appreciated. I tried to get this to work for more than 3 days now.
Finally broke down and put together this post
Published by: mlov83 on Sep 14, 2011 20:48Hello
Thanks for posting the CREATE TABLE and INSERT statemnts; It is very useful.
I'm not sure that understand your needs.
The correct output will be just one line:TOTAL_BUDGET ------------ 700
or will it be 3 ranks that you posted? I guess you want just line after line.
Do you mean that you are given a period (for example, 1).
First you have to find the largest gfl_grnt_year which is related to this period (in this case, 11).
Then you need to add fgl_budget lines that have to be
(1) the specific period and the largest fgl_grnt_year, or
(2) perriod = 14 and the previous fgl_grnt_year (in this case, 10).
Is this fair?If so, here's a way to do it:
WITH got_greatest_year AS ( SELECT fgl.* -- or whatever columns are needed , MAX ( CASE WHEN fgl_period = :given_period THEN fgl_grnt_year END ) OVER () AS greatest_year FROM fgl ) SELECT SUM (fgl_budget) AS total_budget -- or SELECT * FROM got_greatest_year WHERE ( fgl_grnt_year = greatest_year AND fgl_period = :given_period ) OR ( fgl_grnt_year = greatest_year - 1 AND fgl_period = 14 ) ;
If you want the 3 lines you have posted, then change the main SELECT clause to ' SELECT * ' (or, instead of *, youcan the columns you want to see the list).
Maybe you are looking for
-
Satellite Pro A300 - 13 X: Question on the product recovery disks
I recently bought a laptop Satellite Pro A300 - 13 X with Vista Business installed.It came with two product recovery discs to install XP Professional. Given that I decided just to use XP, I followed the procedure for recovery of product and I am now
-
Teredo Tunneling Pseudo-Interface - This device cannot start. (Code 10)
Original title: code10microsoft toledo tunnelling We think we've found a driver but we are not sure because he vomits again code.10
-
Download the new course of Tiger Woods 2008 that are compatible with Windows 7 64 bit
I downloaded the new courses for Tiger Woods 08 when I hac XP but now have Windows 7 64 bit and are unable to download the course. Is this a driver problem? How do I go so I can download these courses?
-
'Please wait until that the current program is finished uninstalling or change'
Im trying to uninstall a program and when I click on uninstall it says: "Please wait unti the current program is finshed uninsatlling or that" it says always that what I'm doing.
-
camera compact xperia z3 button will not work
It's a good time that the camera on my Xperia Z3 compact button does not work. Probably happened after an upgrade of the system, I don't remember you. What is the camera button is to activate the menu bar notification drop down, clearly a software re