Assign months within a range of dates (by almost every day in a given month)
I have a date beginning and end, the sample data as wellSelect to_date('01-13-12','mm-dd-yy') from_dt,
to_date('02-23-12','mm-DD-yy') to_dt
of the double
Union of all the
Select to_date('03-15-2012','mm-dd-yy') from_dt,
to_date('04-16-2012','mm-DD-yy') to_dt
of the double
Union of all the
Select to_date('05-13-2012','mm-dd-yy') from_dt,
to_date('07-23-2012','mm-DD-yy') to_dt
of the double
How can I assign a month by most of the days in a month in this date range? Sometimes the date range can be exactly as many days in a month (as the 15/03/2012 has 16 days and 16/04/2012 16 days). In this case, I want to than the previous month (March).
So according to the data of the sample:
13/01/2012, 23/02/2012, February
15/03/2012, 16/04/2012, March
13/05/2012, 23/07/2012, June
Thank you
Published by: user4422426 on March 1, 2012 17:15
Hello
Here's one way:
WITH cntr AS
(
SELECT LEVEL - 1 AS n
FROM (
SELECT 1 + MAX (to_dt - from_dt) AS max_day_cnt
FROM table_x
)
CONNECT BY LEVEL <= max_day_cnt
)
, got_r_num AS
(
SELECT x.from_dt, x.to_dt
, TRUNC (x.from_dt + c.n, 'MONTH') AS month
, count (*) AS cnt
, ROW_NUMBER () OVER ( PARTITION BY from_dt, to_dt
ORDER BY COUNT (*) DESC
, TRUNC (x.from_dt + c.n, 'MONTH')
) AS r_num
FROM cntr c
JOIN table_x x ON c.n <= x.to_dt - x.from_dt
GROUP BY x.from_dt, x.to_dt
, TRUNC (x.from_dt + c.n, 'MONTH')
)
SELECT from_dt, to_dt
, TO_CHAR (month, 'Mon YYYY') AS mon
, cnt
FROM got_r_num
WHERE r_num = 1
;
Thanks for posting the code to create the same data. Test your code before you post: you've got the reverse order of the arguments to TO_DATE.
Tags: Database
Similar Questions
-
Search a directory of data and display the data that is within the range of dates
Hello
I have a full idrectory of data from overtime, and I think of search in the directory and display the data files for specific dates. I only started this encoding yet but I figure I'll take the brain of some SMEs here labview and start in the right direction. My goal is to go through a comprehensive directory of data taken for a month or MORE csv files and select the data to process and display office files the date of its registration. If I take the data of last week, last month or last minute, it should just treat as an exact or more.
Please help me get started on the right foot
End date will be probably greater than the start date, right? So, end date must connect at the entrance to the upper limit. Then wire in the range? to the conditional terminal of a tunnel of conditional indexation.
Lynn
-
How to get the number of days in a month of belonging to a range of dates
Hi, I'm going crazy around a problem, I have 2 dates and one month I wanto to retrieve the number of days belonging to the months that fall within the range.
for example:
month of January 2011. begin_date = January 11, 2011, May 30, 2011 end_date result is 21
month of January 2011. begin_date = December 11, 2010, result of end_date, January 10, 2011 10
month January 2011 .begin_date = 2 February 2011, end_date may 25, 2011 result 0
month of January 2011. begin_date = January 3, 2011, January 5, 2011 result DATE END 3
and so on...
I appreciate any suggestion
Thank you
AndreaSomething like that... ?
SQL> with t as 2 (select to_date('11/01/11','dd/mm/yy') from_dt, 3 to_date('30/05/11','dd/mm/yy') to_dt, 4 'Jan-11' mnth from dual) 5 select least(last_day(to_date(mnth,'Mon-yy')),to_dt) - 6 greatest(to_date(mnth,'Mon-yy'),from_dt) cnt 7 from t ; CNT ---------- 20
If 0 is also expected...
SQL> with t as 2 (select to_date('11/01/11','dd/mm/yy') from_dt, 3 to_date('30/05/11','dd/mm/yy') to_dt, 4 'Jan-11' mnth from dual union all 5 select to_date('11/01/11','dd/mm/yy') from_dt, 6 to_date('30/05/11','dd/mm/yy') to_dt, 7 'Jan-12' mnth from dual 8 ) 9 select from_dt,to_dt,mnth, 10 greatest( 11 least(last_day(to_date(mnth,'Mon-yy')),to_dt) 12 - 13 greatest(to_date(mnth,'Mon-yy'),from_dt) 14 ,0) cnt 15 from t; FROM_DT TO_DT MNTH CNT --------- --------- ------ ---------- 11-JAN-11 30-MAY-11 Jan-11 20 11-JAN-11 30-MAY-11 Jan-12 0
Published by: JAC on February 9, 2012 19:22
-
I have the following query, which works without problem. This will expand the range of dates, proof of identity, in a list of dates for me:
How can I do this for more than 1 sheet well? for exampleSELECT j_id , date_1 + LEVEL - 1 datum FROM (SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2 FROM DUAL) CONNECT BY LEVEL <= ( date_2 - date_1 + 1);
Thank you.SELECT j_id , date_1 + LEVEL - 1 datum FROM (SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2 FROM DUAL UNION SELECT 456 j_id, TO_DATE('01/02/2012', 'DD/MM/YYYY') date_1, TO_DATE('29/02/2012', 'DD/MM/YYYY') date_2 FROM DUAL) CONNECT BY LEVEL <= ( date_2 - date_1 + 1);
Hello
Here's one way:
WITH cntr AS ( SELECT LEVEL - 1 AS n FROM ( SELECT MAX (date_2 - date_1) AS max_dif FROM table_x ) CONNECT BY LEVEL <= 1 + max_dif ) SELECT x.j_id , x.date_1 + c.n FROM table_x x JOIN cntr c ON c.n <= x.date_2 - x.date_1 ORDER BY x.j_id , c.n ;
If you do any filtering, it may be more effective to do this first. Start the WITH clause with a subquery that performs filtering, then use this result placed instead of your full table in the view online within the cntr as well as in the main query.
For example:CREATE TABLE table_x AS SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2 FROM DUAL UNION SELECT 456 j_id, TO_DATE('01/02/2012', 'DD/MM/YYYY') date_1, TO_DATE('29/02/2012', 'DD/MM/YYYY') date_2 FROM DUAL UNION SELECT 999, TO_DATE ('01/01/2013', 'DD/MM/YYYY'), TO_DATE ('31/12/2013', 'DD/MM/YYYY') FROM dual ; WITH filtered_data AS ( SELECT * FROM table_x WHERE date_1 < TO_DATE ('01/07/2012', 'DD/MM/YYYY') ) , cntr AS ( SELECT LEVEL - 1 AS n FROM ( SELECT MAX (date_2 - date_1) AS max_dif FROM filtered_data ) CONNECT BY LEVEL <= 1 + max_dif ) SELECT f.j_id , f.date_1 + c.n FROM filtered_data f JOIN cntr c ON c.n <= f.date_2 - f.date_1 ORDER BY f.j_id , c.n ;
Published by: Frank Kulash, 27 January 2012 10:10
Posted filtering example -
How to define the range of data to a strict typdef through the control reference
Hello world
I'm trying to define the range of data to a strict typdef through the reference of the order, when I do, I get an 'error of property node.
Is it possible to set the range of the strict typdef.
Thank you
Vignesh
Vignesh1987 wrote:
I'm trying to define the range of data to a strict typdef through the reference of the order, when I do, I get an 'error of property node.
Is it possible to set the range of the strict typdef.
Try to set the original control (type-def) and not its instances... to open the reference of the original type-def command, use 'Open VI reference'.
Published:
These properties are not available with STRICT TYPE DEF.
a. data entry limits: increment property
-
Filter for table data, the range of data obtained and defined 2D
I produce data of an ultrasonic sensor at 1 K Hz, and there is a lot of data (data points range of 0 to 10). However, in some cases when I know that the data should be about 7 (for example) I get outliers (about 9 and 10). Is it possible to define a filter for data in the defined range.
I averaged the data to get an average value, and outliers are distorting. In the worst case, my outliers are 30 to 40% of the data generated. I created a filter to sort the data and, taken from the lowest value. I stop the loop when data reaches a value greater then 9. But this seems to take a long time (because the loop checks for each data point and there are 1000s of them).
Is there a better way to filter data and define a predefined table range to collect?
I enclose my filter.vi... and a set of samples of my previous data. The ranges of data of 10-8 and would like to have the range 7.5 to 8.5 to consider. The sensor records tension here and the problem can be solved by installing a different type of sensor, but if a filter in LabView can due it, the sensor that we use now is absolute.
I am in kind of emergency, my design in unfinished because of this problem, if someone can find some time to share some suggestions, I will be grateful.
Thanks in advance.
See attachment. I have incorporated the data you've posted in the vi. It doesn't seem like any data were less than 8.7 or so, so I modified the scope so it would be a few points on average. Some games were completely out of reach while the average came back like NaN (not a number) due to a division by zero.
-
How to filter for a range of dates calendar events in OS10
In earlier versions of BlackBerry, I used blackberry.find.FilterExpression to filter the events calendar for a specific range of dates.
However for BlackBerry OS10 I scoured the web to find a way to do it. I found:http://developer.blackberry.com/html5/apis/blackberry.pim.calendar.calendarfindoptions.html
I also googled a lot of other sites, but I am unable to understand how to use CalendarFindOptions to refine the calendar of events of a specific timetable. For example, the current week or the next 7 days.
I found this code example...
Function listEvents (limit) {}
Calendar var = blackberry.pim.calendar;
var CalendarFindOptions = calendar. CalendarFindOptions;
var findOptions = {}
'Sort': [{}
"fieldName": CalendarFindOptions.SORT_FIELD_SUMMARY.
'desc': false
}],
'detail': CalendarFindOptions.DETAIL_AGENDA,
'limit': limit
};But unable to find examples how adequately limited by date?
I'm guessing that something like this:
'Start': new Date (' January 1, 2013, 13:00 "): CalendarFindOptions.SORT_FIELD_START.
'end': new Date (' January 1, 2013, 16:00 "): CalendarFindOptions.SORT_FIELD_STOP.But it is an assumption and does not work I can find no example of how do
Any help would be appreciated
See the example for pimcalendar on Github:
https://github.com/BlackBerry/BB10-WebWorks-samples/tree/master/pimcalendar
You can find the JS to set filters of beginning and end starts here:
https://github.com/BlackBerry/BB10-WebWorks-samples/BLOB/master/pimcalendar/index.html#L107
-
Report with 2 settings of filtering by day and 3 measures for a range of dates
Hello
I need to establish a relationship with the following criteria:
(a) I have 5 settings
(b) tell of 2 measures of data should be based on a date 01/01/2015
(c) rest of 3 data measures should be based on a range of dates say 01/01/2015-31/01/2015
No idea how to achieve this? If so please help me.
Thanks in advance
LonaD
You cannot filter the reports by using the filter function in the formula in the column?
-
At least a record exists in details that cover the range of dates
Oracle version:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
Hi gurus
I'm stuck with a scenario and your employees need help to solve this problem.
I have the following table:
Insertion and table creation
drop table ident;
create table ident
(
agreement_id number (5),
ident_pk number (5),
Date of Cov_effective_date,
Date of Cov_termination_date
);
-------------------
Insert ident
(
Select 100,1,to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-31','YYYY-MM-DD')
Union of all the
Select 200,2,to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-12-31','YYYY-MM-DD')
Union of all the
Select 300,3, to_date ('2013-03-01 ',' YYYY-MM-DD '), double null
);
Query on table
Select * ident;
Agreement_id ident_pk Cov_effective_date Cov_termination_date
100 1 13/01/01 13/01/31 200 2 13/01/01 13/12/31 300 3 13/03/01 ------------------------
Drop table ident_dtl;
create the table ident_dtl
(
ident_pk number (5),
ident_dtl_pk number (5),
date of effective_date,
date of termination_date
);
---------------------------------
insert into ident_dtl
(
Select 1-ident_pk, 10 ident_dtl_pk, to_date('2013-01-01','YYYY-MM-DD') effective_date, to_date('2013-01-31','YYYY-MM-DD') termination_date of double - to agreement_id = 100
Union of all the
Select 1,11,to_date('2013-01-01','YYYY-MM-DD'), to_date('2013-01-30','YYYY-MM-DD') of double - to agreement_id = 100
Union of all the
Select 2,12,to_date('2013-01-01','YYYY-MM-DD'), to_date('2013-01-30','YYYY-MM-DD') of double - for agreement_id = 200
Union of all the
Select 2.13, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id is 200
Union of all the
Select 3.14, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id = 300
Union of all the
Select 3.15, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id = 300
);
Query on table
Ident_pk Ident_dtl_pk Effective_date Termination_date
1 10 13/01/01 13/01/31 1 11 13/01/01 13/01/30 2 12 13/01/01 13/01/30 2 13 13/01/01 13/01/15 3 14 13/01/01 13/01/15 3 15 13/01/01 13/01/15 Result of the will
Agreement_Id Ident_pk
200 2
300 3
------------------------------------
There is a single entry in ident against agreement_id and Ident_pk and if you can see that ident_pk is also present in the child table. My requirement is that at least 1 effective_date and child termination_date table must be match/equal to the parent table that is ident cov_effective_date and cov_termination_date against the same column of Ident_pk.
for example:
See the data in Ident_pk = 1, a = cov_effective_date 13/01/01 and its cov_termination_date = 13/01/31 and in the details table against column Ident_pk = 1, you can find that at lease 1 combinaisondes date match against Ident_pk = 1
If you see Ident_pk = 2, then you can't find all the effective_date and termination_date against its corresponding cov_effective_date and termination_date Ident_pk...
Same as 3
-----------
Summary is that there are date range in the ident against agreement_id and Ident_pk table and at least a range of dates even should be exist in detail table is ident_dtl against Ident_pk and if not then show that agreement_id and Ident_pk .
I made this task using PL/SQL, but I think that there is a way to do the same task in SQL. Guide and if you have any questions then please let me know. Thank you
Concerning
Shu
Hello
To be considered as a football game, the same line in ident_dtl must have effective_date and termination_date correspondence?
If so, a solution is:
SELECT i.agreement_id
i.ident_pk
Ident I have
LEFT OUTER JOIN ident_dtl d.ident_pk d = i.ident_pk
AND d.effective_date = i.cov_effective_date
AND d.termination_date = i.cov_termination_date
WHERE d.ident_pk IS NULL
;
Another pure SQL approach to such problems is to use an EXISTS subquery.
-
code to run a process for a range of dates, ignoring Sundays and holidays
I have a proc by name (P_NAME, P_BIZDATE) INS_INVENTORY (P_NAME IS OF TYPE VARCHAR2, P_BIZDATE IS PRESENT). Actuallythis proc runs every day in our Planner. I had to make changes to this procedure. Now, I need to run this proc for P_BIZDATE taking the dates of 1 January 09 to 31 December 09. We also have a table by its PT_HOLIDAYS name, which consists of the list of holidays from 1 January 2009 to 31 December 2009. Now I need a code or a process through which I can run this proc 1 January 09 to 31 December 09 and also this proc should not be run 'SUNDAY' and public holidays as specified in the PT_HOLIDAYS table
CREATE TABLE PT_HOLIDAYS
(
HOLIDAY_DATE DATE NOT NULL,
DISPLAY_NAME VARCHAR2 (35 BYTE) NOT NULL,
)
Insert into PT_HOLIDAYS
(HOLIDAY_DATE, DISPLAY_NAME)
Values
(TO_DATE (1 January 2009 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), "New Year Day");
Insert into PT_HOLIDAYS
(HOLIDAY_DATE, DISPLAY_NAME)
Values
(TO_DATE (25 May 2009 00:00:00 "," MM/DD/YYYY HH24:MI:SS'), "Memorial Day");
Insert into PT_HOLIDAYS
(HOLIDAY_DATE, DISPLAY_NAME)
Values
(TO_DATE (4 July 2009 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'July 4');
Insert into PT_HOLIDAYS
(HOLIDAY_DATE, DISPLAY_NAME)
Values
(TO_DATE (7 September 2009 00:00:00 "," MM/DD/YYYY HH24:MI:SS'), 'Labor Day');
Insert into PT_HOLIDAYS
(HOLIDAY_DATE, DISPLAY_NAME)
Values
(TO_DATE (26 November 2009 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'Thanks Giving Day');
Insert into PT_HOLIDAYS
(HOLIDAY_DATE, DISPLAY_NAME)
Values
(TO_DATE (26 December 2009 00:00:00 "," MM/DD/YYYY HH24:MI:SS'), 'Christmas');
COMMIT;
Please adviceLike this?
declare start_date date := to_date('01/01/2009','MM/DD/YYYY'); end_date date :=to_date('12/31/2009','MM/DD/YYYY'); cur_date date; total_run number := (end_date - start_date)+1; holiday number := 0; begin for i in 1..total_run loop cur_date := start_date + (i-1); begin select 1 into holiday from PT_HOLIDAYS where HOLIDAY_DATE = cur_date; exception when no_data_found then holiday:=0; end; if to_char(cur_date,'DY') != 'SUN' and holiday != 1 then dbms_output.put_line(cur_date||'-'||to_char(cur_date,'DY')); --INS_INVENTORY(
, cur_date) end if; end loop; end; / Kind regards
PrazyPublished by: Prazy on March 29, 2010 12:39
-
Calendar printing problems
I want my mail hot calendar to print like a monthly calendar, as it appears on the screen. The only option I get is a list of every day. How to change that?I could get a link that I sent to my work email, but I wouldn't have to so roundabout. I should be able to go on my hotmail home account, update my calendar and print it like a standard monthly calendar. Help.Hello
Please see the post below for the links to support for all popular Microsoft e-mail programs.
Where can I get help with my questions by e-mail? (Windows 7)-Microsoft Answers:
http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-networking/where-do-i-get-help-with-my-email-questions/461490c7-302b-4cc8-bcd9-127e177d71c3Concerning
-
Is it possible to set up a computer to turn on and turn off itself every day or on any selected date?
Mine is a HP G72-b27CL running Windows 7 64 bit laptop.
Yes can schedule a task to start the system using the option shown in the screenshot below:
You can schedule a task to turn the system off by as shown in the link below:
http://www.thespinningdonut.com/how-to-automatically-shut-down-your-Windows-7-computer/
-
HI everyone, I paid almost 10 days ago, my supcripcion to plan for all the app elements, and after u date of my latest plan, any program is runing, always appear, your time taking, is late, please by the app with my adobe ID works correctly?
Photoshop Elements and Premiere Elements are NOT part of the cloud... you buy a serial number, not a subscription, and you enter the serial number during installation
If you don't want to say things, read below
Your subscription to cloud shows correctly on your account page?
If you have more than one email, you will be sure that you use the right Adobe ID?
https://www.adobe.com/account.html for subscriptions on your page from Adobe
.
If Yes
Some general information for a subscription of cloud
Cloud programs don't use serial... numbers you, connect you to your cloud account paying to download & install & activate... you may need to sign out of the cloud and restart your computer and log into the cloud for things to work
Sign out of your account of cloud... Restart your computer... Connect to your paid account of cloud
-Connect using http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html
-http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
-http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
-http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html
-ID help https://helpx.adobe.com/contact.html?step=ZNA_id-signing_stillNeedHelp
-http://helpx.adobe.com/creative-cloud/kb/license-this-software.html
.
If no
This is an open forum, Adobe support... you need Adobe personnel to help
Adobe contact information - http://helpx.adobe.com/contact.html
Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">===>
-Select your product and what you need help with
-Click on the blue box "still need help? Contact us. "
-
In recent months, every day when I open photoshop, it says the license is not good and I need to contact adobe support...
The WHO and wher can I contact someone who can solve my problems?
(I'm french)
Go to this direct link, then click on 'Chat '. https://helpx.Adobe.com/contact.html?step=PHSP-PHXS_adobe-ID-signing-in_stillNeedHelp
Benjamin
-
How to generate date thru sysdate and day of the week
Hello world!
Please give me a hand with this:
I need calculate a date thru sysdate and day of the week.
For example:
SYSDATE: 22/08/2013
DAY: TUESDAY
Result: 27/08/2013 (the date for Tuesday next from today ' hui).
Another example:
SYSDATE: 22/08/2013
DAY: FRIDAY
Result: 23/08/2013 (the date for Friday next today).
My version of oracle's 8i (I work with a legacy database).
Thanks in advance! ... and sorry for my English
Search the NEXT_DAY function it does exactly what you want
Maybe you are looking for
-
Did Apple Watch nike a faces showing normal?
I'm not sure if a Apple Watch nike + a normal faces? I could not find nike nike faces a worldwide Apple Watch.
-
New watch don't move menu pairing
Hi, I received my new with this morning but he started in Chinese, and even if I type English he won't move to the region and screens of matches. I tried the hard reset but to no avail. Someone at - it ideas?
-
Satellite P300-1EX slow (high) ping - card Atheros AR9281 WLan -.
I just bought the laptop above and fight with insanely high during wireless pings. It is only when connecting via wireless, as when it is connected directly to the router, that is fine. TIA.
-
Blue vertical line on the screen
Hello After a day of use, I have a blue vertical line on the screen. Defective LCD screen? Tried to reapply the latest firmware, but that doesn't change anything. Other things to try before a sent an RMA?
-
How to make a type of file (.doc) always open in a specific program?
original title: How do a (.doc) file type always open in a specific program (my newly installed Word 2010)? I use MS Vista and you have recently installed MS Office 2010 to replace my original MS Office 2003. I want to affect Word 2010 for the progr