List of continuous dates between two dates
HelloI want to list all dates between two given dates (the start_date and the end_date)
where start_date = date minimum a table
and end_date = sysdate
can u please guide how to build queries for this
Thank you
Sadiq
CONNECT BY works from 9i upward. I recommend that an upgrade to a new version of Oracle is not what you expect. Then you need to try the solution object:
SELECT mdv.min_date + ao.rnum - 1 date_in_range
FROM (SELECT rownum rnum
FROM all_objects) ao
, (SELECT MIN (YOUR_DATE_COLUMN) min_date
FROM YOUR_TABLE) mdv
WHERE rownum <= sysdate - mdv.min_date + 1
Tags: Database
Similar Questions
-
the list of numbers between two columns
Hello
I need the list of numbers between two columns.
My source table contains the intervals with different ranges and I'm currently thinking dividing them by size.
I was able to get a solution following the information contained in the Web page:
http://StackOverflow.com/questions/3971981/get-list-of-numbers-in-between-two-columns
The solution I've used is based on the following example:
But this doesn't work in my table if I have few and modest intervals (maximum 5 digits range).with t as ( select 10 startnum, 15 endnum from dual union all select 18, 22 from dual union all select 10000, 19999999999 from dual ) select lvl from (select level lvl from dual connect by level <= (select max(endnum) from t)) a where exists ( select 1 from t where lvl between t.startnum and t.endnum )
In the example, I was trying to understand why this might be failing, but I do not have a conclusion yet.
There is something I noticed and that I try to understand, that is:
If I change this query to:
It will increase from 2 to 3 seconds to return results to a few minutes at least (canceled after a few minutes!)with t as ( select 10 startnum, 15 endnum from dual union all select 18, 22 from dual union all select 19999999990, 19999999999 from dual ) select lvl from (select level lvl from dual connect by level <= (select max(endnum) from t)) a where exists ( select 1 from t where lvl between t.startnum and t.endnum )
Thus, using this example to understand if my problem is related to having many between start and end number or if it is linked with having small intervals between large numbers.
Can someone explain to me why I have this speed of different treatment depending on the value of the interval? And why it takes longer with the small interval?
I need to apply it to different beaches (from 2 ranges of numbers to 16 range) and in all ranges, I will have small intervals to check.
For example:
endnum startnum
7341 7342
7422-7423
7439 7456
2522200050 2522200054
2522200146 2522200150
4216969839880 4216969839884
4216969839893 4216969839897
Having this problem I can only ask the first values I have in the picture!
Best regards
Ricardo TomasHi, Ricardo,
Here's one way:
WITH cntr AS ( SELECT LEVEL - 1 AS n FROM ( SELECT MAX ( endnum - startnum) AS max_diff FROM t ) CONNECT BY LEVEL <= max_diff + 1 ) SELECT startnum + c.n FROM t JOIN cntr c ON t.endnum >= t.startnum + c.n ;
In your original query, you generate all the numbers from 1 to the highest endnum. You only need enough numbers to cover the range of startnum to endnum. (This method also works if startnum is less than 1).
Joins are usually faster than EXISTS subqueries. -
List of years between two dates
Hello
I am new to Livecycle Designer and learning I will.
I have a few questions related to the same question.
1. is it possible to create a list of years between two dates, especially the exercises? (I'm in Australia so it's July 1 to June 30).
for example
User between two dates in date fields:
(Start Date of the project field) July 1, 2012 and (end Date of the project field) 30 June 2015
Have an auto list to fill out as below:
(List)
2013
2014
2015
or ideally
(List)
2012/13
2013/14
2014/15
linking this (if possible).
2. is it possible to have to repeat the lines created automatically in a table for each of the fiscal years indicated in the list above?
If either / both of them are possible help that someone could provide would be very appreciated.
Thank you
Ivan
Hello
Please find an example that shows what I think you would do here - https://workspaces.acrobat.com/?d=F9t-rLq3bapw2d-XY0dRuQ
I ran a few test cases and did not include the error handling to keep the code as easy to read as possible.
If you open the form and look at the code in the click event of the update button, then that's where all the magic happens.
Hope this helps
Malcolm
-
Need help on the list of months between two Dates
Hi all
I have a table which has startdate and enddate and need a select to list all the months between these two dates for each given ID.
I did some tests and could not figure out how to get the startdate and enddate table (instead of hard coding) tests in the select statement.
Could someone please help on this (Oracle 11 g 2),
Thanks in advance!
create table testing( id number, start_date date, end_date date); insert into testing values(100, to_date('05-FEB-2011', 'DD-MON-YYYY'), to_date('28-MAY-2011', 'DD-MON-YYYY')); insert into testing values(200, to_date('20-JUN-2011', 'DD-MON-YYYY'), to_date('28-DEC-2011', 'DD-MON-YYYY')); commit; select * from testing; ID START_DAT END_DATE ---------- --------- --------- 100 05-FEB-11 28-MAY-11 200 20-JUN-11 28-DEC-11 Elapsed: 00:00:00.01 *for testing.id = 100:* select to_char(add_months(to_date('05-FEB-2011', 'DD-MON-YYYY'), l - 1), 'YYYY-Mon') Dates from (select level l from dual connect by level <= months_between(trunc(to_date('28-MAY-2011', 'DD-MON-YYYY'), 'MONTH'), trunc(to_date('05-FEB-2011', 'DD-MON-YYYY'), 'MONTH')) + 1); DATES ----------------- 2011-Feb 2011-Mar 2011-Apr 2011-May Elapsed: 00:00:00.01 *for testing.id = 200:* select to_char(add_months(to_date('20-JUN-2011', 'DD-MON-YYYY'), l - 1), 'YYYY-Mon') Dates from (select level l from dual connect by level <= months_between(trunc(to_date('28-DEC-2011', 'DD-MON-YYYY'), 'MONTH'), trunc(to_date('20-JUN-2011', 'DD-MON-YYYY'), 'MONTH')) + 1); DATES ----------------- 2011-Jun 2011-Jul 2011-Aug 2011-Sep 2011-Oct 2011-Nov 2011-Dec 7 rows selected.
SQL> select * from testing 2 / ID START_DAT END_DATE ---------- --------- --------- 100 05-FEB-11 28-MAY-11 200 20-JUN-11 28-DEC-11 SQL> select id, 2 to_char(add_months(start_date,column_value - 1),'YYYY-Mon') dates 3 from testing, 4 table( 5 cast( 6 multiset( 7 select level 8 from dual 9 connect by add_months(trunc(start_date,'MM'),level - 1) <= end_date 10 ) 11 as sys.OdciNumberList 12 ) 13 ) 14 order by id, 15 column_value 16 / ID DATES ---------- -------- 100 2011-Feb 100 2011-Mar 100 2011-Apr 100 2011-May 200 2011-Jun 200 2011-Jul 200 2011-Aug 200 2011-Sep 200 2011-Oct 200 2011-Nov 200 2011-Dec 11 rows selected. SQL>
SY.
-
FabricPath or OTV between two data center using Direct fiber cable
Hello
I have two data center both of them has the same equipment N7k, N5k and N2k, and we want the dataCenter being active/active, I'm really confused to use OTV or FabricPath characteristic, if someone can help me with my scenario and explain to me what is the best solution and advantage and disadvantage between OTV and PabrcPath.
Many thanks in advance
Hi Steven,
No problem, I'll go through your points as completely as possible. I advise you to read more about these protocols, maybe if you have access to INE or similar, see their videos on this. I would also like to say again that I have not seen all documentation Cisco indicating that FabricPath to be used as a DCI.
With regard to the way fabric you ask what follows...
1. only can use it between two datacenters of you have more we can't, please correct me?
No, you can use the path of fabric with more than two data centers, but even with OTV, you can use it with more than two data centers.
2. HSRP localization can not be implemented as OTV. However You can have two differnet Gateways at the Data Center 1 and 2 using two different HSRP groups. If server is moved dynamically from, (i didn't understand this point can you please explain with example?
OK, so this is a GREAT topic. Location of HSRP CAN be implemented with OTV, but cannot be implemented with fabric path. First hop redundancy protocols can be localized and is supported by Cisco with OTV, this basically allows the same default gateway to reside in two of your data centers providing the ACTIVE/ACTIVE configuration. So no matter where your VM is, they did not change their default, even if gateway your servers to move to the other datacenter.
If we didn't have this, we would have only an active member of HSRP divided between DC and things would be extremely troublesome in regard to traffic flows. A virtual machine in DC2 VLAN needs to talk to host in VLAN B. But the default gateway is completely in DC1. So frame is sent to the ICD in DC1, then the gateway by default, routes packets VLAN B. This VLAN B lies in fact in DC2, so now it has to go all the way back to DC2. You get my point...? :)
With localization happen only local to the domain controller. If all servers / VMS in the domain controller can speak locally to its "own" default gateway.
3. unknown unicast flooding (can you give me an example?)
Unknown unicast traffic is unicast packets/images with unknown destination mac address. By default, switches are flooding this type of traffic to all ports in the VLAN. With path of fabric that would take place during your DCI, but with OTV, it is all taken care locally, so massive savings on bandwidth here and it is much more effective.
4. ARP optimization between Data Center (can you give an example regarding ARP optimization?)
There is another function of OTV, which makes it far superior on the way of tissue. Essentially, we are reducing the volume of traffic passing through the transport infrastructure (i.e. ICD)
When ARP, host in DC1 to host that responds in DC2, we use links and there is travel time of package that might be minimal, but is not the most optimal. OTV AED - or edge device spy ARP response and subsequently knows that this mapping exists from there. ARP takes place after the first Protocol, the EDA almost proxy ARP to DC1 so the ARP request locally does not have to travel to DC2.
5. Typically two flows (Odd VLANs by OTV-VDC-1 and even vlans by OTV-VDC-2) carry the entire layer 2 traffic flow between the two Data Centes. Hence the load balancing the links is not efficient. ( (can you explain compare with FabricPath if you have example?)
IMHO, it's bad and good. Balance the workload of the OTV if you have more than an AED on site. VLAN strange appointment via an AED, even numbered VLAN go through the other. Depending on traffic on VLANs, this could become unbalanced. Fabric used by all its links to mac addresses 'route' to the respective SID - ID switch she needs to do. So perhaps a better uniformity of split here.
6. VLAN scalability for OTV is lower than FabricPath as of this content writing. (can you explain what this mean i didn't understand it)
I completely disagree with this comment. I too do not understand.
7. Resiliency of FabricPath network is better than OTV in some failure scenarios.(can me an example ?)
I also disagree with that. Resilience of path of fabric could be same as OTV or perhaps better. However, my personal experience is that OTV fine tuning with things like BFD failover is much faster!
Fabric is good because the control of aircraft ISIS and its operation is admirable, but could say the same for the OTV.
Lets say one of the DCI links had to die, the transmission of the tissue path would continue through the other links, then perhaps for low latency, high frequency, environments that would be beneficial. OTV will change the EDA and re - learn mac, announced by other AEDS, addresses, but as I said, the time could be extremely minimal and tuning. This isn't a big deal, unless you need under second time convergence!
I hope that I have answered your questions, I recommend use for your DCI OTV, use the path of fabric for your inside of local switching in your DC. This has been implemented repeatedly and the links I sent you the models validated Cisco also point out.
Remember - fabric has been built to be a step towards TRILL, and replacement of protocols spanning-tree, OTV was built especially for the dci. They are both built and examples of specific design. It makes no sense to get these confused or mixed up, unless there is a real and pressing the case.
Joel conclusion is right, use the right tools for the job. If the use case is good for the FP then OK, if not, OTV.
Rcmnd - reading http://www.packetmischief.ca/2013/04/23/DCI-series-overlay-transport-vir...
These are just my thoughts.
Bilal (CCIE #45032)
-
Calculate the hours between two dates
Hello
I have a requirement to count the hours with 2 given timestamps, something like:
However, I wish it would be that simple. I just need to count the hours between two timestamps for the hours of work for example, 08:00 - 17:00, MONDAY to Friday (excluding weekends).SQL> select ((to_date('22-oct-2012 13:00:00','dd-mon-yyyy hh24:mi:ss') - to_date('20-oct-2012 13:00:00','dd-mon-yyyy hh24:mi:ss'))*24) B from dual ; B ---------- 48
So lets say I have to count the hours between two dates above the result should be 18 hours not 48 (4 hours on 20/oct, 9 hours on 21/oct to 5 hours 22/oct).
How can I achieve this? Any idea will be useful.
Thank youMy query generates a list of all the hours between the start and end time, filters on the hours that are outside of the hours of work and then account for the remaining lines. Change that to partial hours must just be a case of replace the two occurrences of 1/24 with 24/01/60, then - as say you - Division COUNT (*) by 60.
There may be performance issues using techniques of generation of line like this, if you put this in a query involving the joining of several lines of other tables (for example where the dates of beginning and end are derived from several employees?) or in several days. If you don't find it then count the number of whole days (taking weekends into account) between dates and work on the partial days after that it could be better. This would probably involve a lot of statements of case (which I don't have time to test it now).
Ben
-
Behavior of days between two dates
Hello!
If anyone can help? ... with differences in Date? :
All I want is to calculate the number of days between two dates:
InitDate has been entered as 01/10/2010 planning, to recover is 20101001
HireDate was entered into the 1980-10-01 planning, to recover is 19801001
I tried
NumDays = @DATEDIFF (InitDate, HireDate, DP_DAY);
but give me only 0 and -1.
When I try the regular difference:
NumDays = InitDate - HireDate;
He returned to 30,000 (which in the example is 20101001-19801001) - which should not.
I use Essbase/Planning 11.1.1.2, I tried also to break dates in years and months using INT and operations, but when I want to get the calendar days he is ugly. The two dates live in the same block.
Someone at - it an idea?
Thank you very much!Hello
Here's a piece of code in my trunk of code which may help you. This assumes you have string CDF pack (https://www.samplecode.oracle.com/tracker/tracking/linkid/prpl1004/remcurreport/true/template/ViewIssue.vm/id/S441/nbrresults/9)var y1, y2, m1, m2, d1, d2, difx1, difx2;
FIX (SOLUTION YOUR MEMBERS HERE)
"BLOCK MEMBER")Y1=@round ("Date of 1" / 10000,0);
Y2=@round ("Date 2" / 10000,0);
M1=@round (("Date 1"-y1*10000)/100, 0);
M2=@round (("Date 2"-y2*10000)/100, 0);
D1 = ' Date of 1 "-(y1*10000+m1*100);"»
D2 = "Date 2"-(y2*10000+m2*100); "»difx1=@TODATEEX ("mm/dd/yyyy",
@JconcatStrings (@LIST (@JgetStringFromDouble (m2,@_false,@_false), ' / ', @JgetStringFromDouble (d2,@_false,@_false), ' / ', @JgetStringFromDouble (y2,@_false,@_false)))
)
) ;
difx2 = @TODATEEX ("mm/dd/yyyy", @JconcatStrings (@LIST)
@JgetStringFromDouble (m1,@_false,@_false), ' / '.
@JgetStringFromDouble (d1,@_false,@_false), ' / '.
@JgetStringFromDouble (y1,@_false,@_false))
)
);diff=@DateDiff (difx2, difx1, DP_DAY);
)
ENDFIXSee you soon,.
Alp -
photo selection between two dates
In Photos
It is possible to select photos between two dates?
In Photos,.
is it possible to select the photos between two dates?
Thank you, thank you
Yes. With a smart album like this:
-
How do you find the average value of all the data between two points on a single channel
I'm tring to calculate the average value of all data points in a single field between two distinct points
I rasthaus an illustration.
Hi smoothdurban,
I thought you wanted to specify the area of interest with the sliders of the band. If you rather automatically define the area of interest based on thresholds, etc., we cannot see the interactive nature of the example I sent.
What are the criteria used to determine the start and end of the region of interest lines?
I would be able to type this out for you if you sent a representative data set ([email protected])
Brad Turpin
Tiara Product Support Engineer
National Instruments
-
Difference between two data aquistion
Hello
I got a data aquistion system that is supposed to keep data acquisition selection until the difference between two points a lot. For example, I get voltage (mv) as 2.31, 2.32, 2.34. 2.33 2.32, 2.33 2.32. the data up to a point, say 0.1V higher or lower than the first. Thewhole procss stop. Thank you for your suggestions.
Try this... (Labview 8.2)
-
MaxL Script to clear the data between two dates
Hi all
I need advice to clear the data between two dates, I have three dimensions in my sketch, 'eno', 'hiredate' and the 'actualamount '.
Now I need to erase the data between the date range, up to now, I have this script,
Fix ("HireDate", "Eno")
Difficulty (@relative ("00:00:00",0),@relative("eno",0)) 2015-07-15 "))
CLEARDATA "sal."
endfix
ENDFIX
These scripts only clears on a specific day, but I tried to write the script to clear between two dates, I surfed on a few sites, but no clear answers, finaanly came here, kindly help in this regard.
Thanks in advance.
Have you not tried the format of "startdate":"enddate" for example "August":"September."
See you soon
John
-
Dynamic calculation of the number of days between two dates in a table
Hello
I'm working on request where I dynamically calculate the number of days between two dates in a table.
The calculation must be dynamic, i.e., when I recover the Start_date and End_date and move to the field following (call_duration) in the same row, the difference must be calculated dynamically in this area and make sure the field read-only.
APEX version: 5.0
Hi BO123,
BO123 wrote:
Hello
I'm working on request where I dynamically calculate the number of days between two dates in a table.
The calculation must be dynamic, i.e., when I recover the Start_date and End_date and move to the field following (call_duration) in the same row, the difference must be calculated dynamically in this area and make sure the field read-only.
APEX version: 5.0
one of the way to do this by calling ajax on change of end_date.
See the sample code given below to fetch the resulting duration and making the field read only after calculation
Step 1: Change your page
under CSS-> Inline, put the code below
.row_item_disabled { cursor: default; opacity: 0.5; filter: alpha(opacity=50); pointer-events: none; }
Step 2: Create on demand Ajax process I say CALC_DURATION
Please check Procces Ajax, see line 6.7 How to assign a value to the variable sent by ajax call
Declare p_start_date date; p_end_date date; p_duration number; Begin p_start_date := to_date(apex_application.g_x01); p_end_date := to_date(apex_application.g_x02); --do your calculation and assign the output to the variable p_duration select p_end_date - p_start_date into p_duration from dual; -- return calculated duration sys.htp.p(p_duration); End;
Step 3: Create the javascript function
Change your page-> the function and the declaration of the Global Variable-> put the javascript function
You must extract the rowid in the first place, for which you want to set the time, see line 2
assuming f06, f07 and f08 is the id of the start date, and end date columns respectively, and duration
See no line no 8 how set the value returned by the process of ajax at the duration column
Replace your column to the respective column identifiers in the code below
function f_calulate_duration(pThis) { var row_id = pThis.id.substr(4); var start_date = $('#f06_'+row_id).val(); apex.server.process ( "CALC_DURATION", { x01: start_date,x02: $(pThis).val() }, { success: function( pData ) { // set duration to duration column $('#f08_'+row_id).val(pData); // disable duration column $("#f08_" + row_id).attr("readonly", true).addClass('row_item_disabled'); } }); }
Step 4: choose the end date call the javascript function
Go to report attributes-> edit your Date column end-> column-> Attrbiutes element attributes-> put the code below
onchange="javascript:f_calulate_duration(this);"
hope this helps you,
Kind regards
Jitendra
-
difference between two dates in the year/month/day in Obiee
Hi gurus,
I know this question have been asked and answered several times but I have a requirement that is a little different, then the previous ones.
I want to calculate the difference between two dates in OBIEE10g in year/month/day format similar to the below SQL output
SQL > select end_date, start_date,
trunc (months_between (end_date, start_date) / 12) years.
months of mod (trunc (months_between (end_date, start_date)), 12).
End_date - add_months (start_date, trunc (months_between (end_date, start_date))) days
t
Thanks in advance
SK
Search for this
"TIMESTAMPDIFF IN THE FORM OF MTHS # YEARS."
or else
To get the current mandate of employees since the date of hiring in the form of # years # mths or # year (s) # month (s)
Concat (concat (cast (TIMESTAMPDIFF (SQL_TSI_Month, "Employee attributes". (((' ' Hiring last Date employee ", CURRENT_DATE) / 12 as char),"Year (s)"), concat (cast (MOD (TIMESTAMPDIFF (SQL_TSI_Month,"Employee attributes". (((((' ' Hiring last Date employee ", CURRENT_DATE), 12) as char), 'Month (s)'))
Concat (concat (CAST (TIMESTAMPDIFF (SQL_TSI_YEAR, "Employee attributes". (((' ' Hiring last Date employee ", CURRENT_DATE) as CHAR),"Year (s)"), concat (cast (MOD (TIMESTAMPDIFF (SQL_TSI_Month,"Employee attributes". (((((' ' Hiring last Date employee ", CURRENT_DATE), 12) as char), 'Mth (s)'))
-
Number of Saturdays between two dates
Hello
How can I get number of Saturdays between two dates, including the two dates?
for example number of Saturdays between 09/05/2014 and 10/05/2014 is five
Help, please
I use oracle 10g
SQL> with t 2 as 3 ( 4 select to_date('05/09/2014 ', 'dd/mm/yyyy') from_dt 5 , to_date('05/10/2014 ', 'dd/mm/yyyy') to_dt 6 from dual 7 ) 8 select to_char(from_dt + (level-1), 'fmDay') day_ 9 , count(*) cnt 10 from t 11 connect 12 by level <= to_dt - from_dt + 1 13 group 14 by to_char(from_dt + (level-1), 'fmDay'); DAY_ CNT --------- ---------- Saturday 5 Thursday 4 Tuesday 4 Friday 5 Wednesday 4 Monday 4 Sunday 5 7 rows selected. SQL>
-
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
Maybe you are looking for
-
Looking to turn my on my HP laptop fingerprint reader. This is confirmed working correctly in normal applications, and when you use IE. I'm moving and it is one of the last points with which I struggle. Y at - it a required plugin? It's just being bl
-
What is Apple doing to correct this failure problem, colossal, with update!
-
I'm just my front camera of pluse iPhone 6 have manufacturer fault do I do
I have iPhone 6 pluse about a year, still problems with camra fron to read on the internet, it is made fault I just want to know what I'd do
-
Hello I have a service online Internet with 5 public IP addresses. The router and the AP are connected to a switch. I would like to set up a WRT54G Router with a public IP address and use DHCP (with private ip address) for the computers that will con
-
I had 2-3 games tell me that, I have all the updates to my graphics card, all windows updates, I actually found the file on my computer, why what is happening? and how to fix it? Games: Hit Rise of the tribes my computer has the requirements to play