Add months to ore.date
Is it possible to add months on ore.date without ore.pull?
Example:
Version 1.4 of ore
> DATE <-ore.push (seq (also. Date("1999/1/1"), by = "3 month", length = 2)) [2]
> DATE
[1] "1999-04-01.
> class (DATE)
[1] "ore.date".
attr(,"package")
[1] "OREbase".
>
> NEW_DATE <-seq (DATE = '3 month', length = 2)
Error in seq.int (r1$ Lun, by =, length.out = length.out):
"provenance" should be finished
Currently the ore.datetime feature to perform aggregates and summaries, comparisons, extract values and constraints.
In order to modify the datetime object, you can shoot locally using ore.pull:
DATE<- ore.push(seq(as.date("1999/1/1"),="" by="3 months" ,="" length="">->
Date<->->
new_date<- seq(mydate,="" by="3 months" ,="" length="">->
NEW_DATE<->->
Class (NEW_DATE)
R > NEW_DATE
[1] "1999-04-01" "1999-07-01".
R > class (NEW_DATE)
[1] "ore.date".
attr(,"package")
[1] "OREbase".
I'll add an improvement to enable this feature for a future version of ore.
Sherry
Tags: Business Intelligence
Similar Questions
-
How to add a month to a date?
Hello
I have the following stored procedure corresponding to the syntax < month > I am after. I think that the code is pretty self-explanatory, but if something is clear so please ask :)
CREATE or REPLACE PROCEDURE &HKResourceDB_Schema_Name..UpdateSubscriptionDates ( aGroupID NUMBER ) AS BEGIN UPDATE HKGroup SET SubscriptionStarted = CAST(SYS_EXTRACT_UTC(LOCALTIMESTAMP) AS DATE), SubscriptionEnded = CAST(SYS_EXTRACT_UTC(LOCALTIMESTAMP) AS DATE) + <one month> WHERE ID = aGroupID; END UpdateSubscriptionDates; /
What is the use of it to add months simply use add_months() function
SQL> select to_char(sysdate,'dd-mon-yyyy') from dual; TO_CHAR(SYS ----------- 10-sep-2009 -- NOW ADD MONTHS AS BELOW SQL> select to_char(add_months(sysdate,1),'dd-mon-yyyy') from dual; TO_CHAR(ADD ----------- 10-oct-2009
-
Hi Experts,
I want every month in two dates:
I have change in output.
Select TO_DATE (' 02/02/2003 ', ' dd/mm/yyyy') as start_date, TO_DATE (' 02/02/2003 ', ' dd/mm/yyyy') as double end_date
Description: I have a month (2)
Desired output
months of the year
---- -----
2 of 2003
Select TO_DATE (' 2003/02/25 ', ' dd/mm/yyyy') as start_date, TO_DATE (' 2003/03/01 ', ' dd/mm/yyyy') as double end_date
Description: I have two months (2.3)
Desired output
months of the year
---- -----
2 of 2003
3 2003
Select TO_DATE (' 28/12/2003 ', ' dd/mm/yyyy') as start_date, TO_DATE (' 2004/04/01 ', ' dd/mm/yyyy') as double end_date
Description: I have 5 months (2003:12, 2004: 1, 2, 3, 4)
Desired output
months of the year
---- -----
12 2003
2004 1
2 2004
2004 3
4 2004
Thanks in advance
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - production
Post edited by: Ràmio
This...
-Started test data
WITH qry AS
(select TO_DATE (' 02/02/2003 ', ' dd/mm/yyyy') as start_date, TO_DATE (' 02/02/2003 ', ' dd/mm/yyyy') as double end_date)
UNION ALL
Select TO_DATE (' 2003/02/25 ', ' dd/mm/yyyy') as start_date, TO_DATE (' 2003/03/01 ', ' dd/mm/yyyy') as double end_date
UNION ALL
Select TO_DATE (' 28/12/2003 ', ' dd/mm/yyyy') as start_date, TO_DATE (' 2004/04/01 ', ' dd/mm/yyyy') as double end_date
)
-Test data that ended
SELECT start_date,
End_date,
EXTRACT (YEAR OF ADD_MONTHS (start_date,(LEVEL-1))) year.
EXTRACT (MONTH FROM ADD_MONTHS (start_date,(LEVEL-1))) Lun
OF qry
CONNECT BY LEVEL<=>=>
AND PRIOR start_date = start_date
AND PRIOR DBMS_RANDOM. VALUE IS NOT NULL.
OUTPUT:-
========
START_DATE END_DATE YR LUN
---------- --------- ---------- ----------
2 FEBRUARY 03 2003 2 FEBRUARY 03 2
25 FEBRUARY 03 2003 1 MARCH 03 2
25 FEBRUARY 03 2003 1 MARCH 03 3
28 DECEMBER 03 2003 1 APRIL 04 12
28 DECEMBER 03 2004 1 APRIL 04 1
28 DECEMBER 03 2004 1 APRIL 04 2
28 DECEMBER 03 2004 1 APRIL 04 3
28 DECEMBER 03 2004 1 APRIL 04 4
8 selected lines
Thank you
Ann
-
Is there one way other than to_char to get the month of the date field
Is there one way other than to_char to get the month of the date field
Hello
raj4tech wrote:
Is there one way other than to_char to get the month of the date field
EXTRACT is one:
SELECT INTERESTED (SYSDATE MONTHS) AS curr_month
DOUBLE;
-
Hello
I have two dates. start date and end date.
I want to extract months between two dates
months should be as
JAN
FEB
MAR
for example.
Start - 1-jan-2014
date of end - 31 - dec - 2014
How can I do this?
Thanks and greetings
CORINE
You should always use the function MONTHS_BETWEEN...
for example
SQL > ed
A written file afiedt.buf1 with t as (select date '' 2014-01-01 as start_date date ' 2014-12-31' as double end_date)
2 --
3 end of test data
4 --
5. Select to_char (add_months (start_date, rownum-1), 'My') by month
6 t
7 * connect by rownum<=>=>
SQL > /.LUN
---
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Ms
Oct
Nov
Dec12 selected lines.
And if you want that they display, separated by commas...
SQL > ed
A written file afiedt.buf1 with t as (select date '' 2014-01-01 as start_date date ' 2014-12-31' as double end_date)
2 --
3 end of test data
4 --
5 Select listagg (to_char (add_months (start_date, rownum-1), 'My'), ',') group by month (order by rownum)
6 t
7 * connect by rownum<=>=>
SQL > /.MONTH
-----------------------------------------------------------------------------------------------------------------
Jan, Feb, Mar, Apr, may, June, July, August, Sept, Oct, Nov, Dec -
2 writers can add to the same data staged?
HelloHow can we get 2 entries to write on the same data staged without data loss? I need to write the rejected records to a staging of data in 2 different processes before exporting.
Kind regards
Ravi
No, you can not do this. Ecrire write to different sets of data on stage, then use a process with the merge data stream to bring together them.
Otherwise, use two different sets of data staged or data interfaces and add to export. Data interfaces means that you never staged. The staged data: you can choose whether or not to step in the configuration of the task (or run profile).
-
How to calculate the number of days/weeks/months between 2 dates?
Hello
I would like to know how to calculate the number of days/weeks/months between 2 dates in OBIEE 11 g, for example, I have 26/05/2013 and 19/05/2013, then I want to get 7 days.
Thank you!
JamieHi Jamie,
Through this links...
http://www.bravesoft.com/blog/?p=682
http://twobiee.blogspot.in/2012/01/working-with-date-differences.htmlMark as correct it allows u...
Thank you... -
Gets the number of months to a Date
Hello
I use the version of database Oracle 11.2.1. I would like to calculate the number of fiscal month of a date.
For example:
Date: 31/03/2013
Fiscal No. month: 12
The fiscal year runs from 01 - Apr-31 - March each year.Hello
You can use
EXTRACT (MONTH FROM (ADD_MONTHS (mydate, -3)))
Example:
WITH mytable AS ( SELECT TRUNC(SYSDATE) - 400 + LEVEL mydate FROM DUAL CONNECT BY LEVEL <= 400) SELECT mydate, EXTRACT (MONTH FROM (ADD_MONTHS (mydate, -3))) fiscal_month FROM mytable WHERE mydate = TRUNC (mydate, 'MM') OR mydate = LAST_DAY(mydate); MYDATE FISCAL_MONTH --------- ------------ 31-MAR-12 12 01-APR-12 1 30-APR-12 1 01-MAY-12 2 31-MAY-12 2 01-JUN-12 3 30-JUN-12 3 01-JUL-12 4 31-JUL-12 4 01-AUG-12 5 31-AUG-12 5 01-SEP-12 6 30-SEP-12 6 01-OCT-12 7 31-OCT-12 7 01-NOV-12 8 30-NOV-12 8 01-DEC-12 9 31-DEC-12 9 01-JAN-13 10 31-JAN-13 10 01-FEB-13 11 28-FEB-13 11 01-MAR-13 12 31-MAR-13 12 01-APR-13 1
Kind regards.
Al -
How can I add days to a Date value in a Script time?
How can I add days to a Date value in a Script (XPATH) time?XPATH:
Add Date:
xs:dateTime($yourCurrentDateVar) + xs:dayTimeDuration($yourDuration)
Difference in date:
move "fn:days-from-duration(xs:dayTimeDuration(xs:date($yourCurrentDateVar) - xs:date($yourPrevDateVar)))" to $diff;
You did not mention the version of the Framework, you can take advantage of the Business Service (BS) to perform Date calculations, for example, for FW2.2.x, you can use BS: C1-DateMath with such options as the 'Resistance' to add to the Date, "DIFF" for Date-Diff and FW4.x, you can use BS: F1-DateMath with options such as "F1AD" to add to the Date etc.
Find out more about XPATH herefunction.
-
Get the number of months between the dates.
Hi I need to get the exact number of months between the dates. So if I'm Sysdate - to_date(31-JAN-2011) I should get something like 8.4 months. Months_between function doesn't quite give me what I need. Is it possible that I can do this?876056 wrote:
Hi I need to get the exact number of months between the dates. So if I'm Sysdate - to_date(31-JAN-2011) I should get something like 8.4 months. Months_between function doesn't quite give me what I need. Is it possible that I can do this?I don't see how you get 8.4 months. The counted months are February, March, April, may, June, July, August and, as of today, 9 and change the days of September. Unless I forgot the lessons of counting, I learned in kndergarten is 7 full months and a bit.
Maybe you want something like:
SQL> select months_between(Sysdate, to_date('01-JAN-2011', 'dd-mon-yyyy')) mb, 2 (Sysdate - to_date('01-JAN-2011', 'dd-mon-yyyy'))/30 div30 3 from dual; MB DIV30 ---------- ---------- 8.27800142 8.38726813
If you get the form date a table, you can use trunc (date_column, 'mm') at the date of the first day of the month.
John
-
Display the months between two dates
Hello:
I need all the months between two dates. I entered two dates as January 15, 2001 and 2011-mar-03. I want the result as below.
JANUARY 15, 2011 - JANUARY 31, 2011
February 1, 2011 - February 28, 2011
MARCH 1, 2011 - MARCH 3, 2011
I held this result of sql query in oracle. Could you please suggest me?
Thanks in advance.
AbhishekSELECT GREATEST(st, ADD_MONTHS(TRUNC(st, 'MONTH'), (LEVEL - 1))) dt, LEAST(ed, LAST_DAY(ADD_MONTHS(TRUNC(st, 'MONTH'), (LEVEL - 1)))) ld FROM (SELECT DATE '2011-01-15' AS st, DATE '2011-03-03' AS ed FROM DUAL) CONNECT BY LEVEL <= MONTHS_BETWEEN(TRUNC(ed, 'MONTH'), TRUNC(st, 'MONTH')) + 1 ORDER BY 1; DT LD ------------------------ ------------------------ 15.01.2011 00:00:00 31.01.2011 00:00:00 01.02.2011 00:00:00 28.02.2011 00:00:00 01.03.2011 00:00:00 03.03.2011 00:00:00
HTH, Urs
-
Add days to a date is to be indented by year.
Hello
I have the problem on Oracle 10 g. I have run the following statement that adds 1 to a date, but, unless I have format, the date is back with a year less than expected.
Has anyone ever seen anything like that?SQL> select effective_date, (effective_date + interval '1' year(1)) as addyear, add_months(to_date(to_char(effective_date, 'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'), 12) as addyearformat from price_change where price_change_id = '794328' ; EFFECTIVE_DATE ADDYEAR ADDYEARFORMAT --------------- --------------- --------------- 28-SEP-09 28-SEP-08 28-SEP-10
Effective_date is of type date and has data in the format "MM/DD/YYYY HH24:MI:SS. I think it's something with the format, perhaps something to do with the zone - not sure. If I just insert a value into the table with the format ' MM/DD/YYYY HH24:MI:SS' I don't have this problem. I don't know how the date could have been modified to do that, but I know not to go through a time zone function before be inserted in this table, but I don't know if that is the cause of the problem.
Don't know if it's important but nls_database_parameters...
VALUE OF THE PARAMETER
NLS_DATE_FORMAT dd-MON-rr
NLS_TIMESTAMP_FORMAT-DD-MON-RR HH.MI. SSXFF AM
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI. SSXFF AM TZR
NLS_TIME_FORMAT HH.MI. SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI. SSXFF AM TZR
Thanks for any help in advance.
Published by: amcgator on October 15, 2010 11:52amcgator wrote:
In fact, this would explain why, if I do not pass the end of the year mark (IE if I just add 30 days), everything looks OK. How in the world that is possible, or how can I confirm this?Did you read my response? Question:
select to_char(effective_date,'mm/dd/yyyy bc') from price_change where price_change_id = '794328' /
If you see bc - it's confirmed :).
SY.
-
get all the date of end of months between two dates
Hi all, I'll try to find together the date of end of months between two dates.
I have the following data in a table
WITH AS's Data1
(
SELECT To_Date('4/30/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual UNION ALL
SELECT To_Date('5/01/2009','mm/dd/yyyy') dt, "TEST2" lname FROM dual UNION all
SELECT To_Date('5/02/2009','mm/dd/yyyy') dt, "TEST3" lname FROM dual UNION all
SELECT To_Date('5/03/2009','mm/dd/yyyy') dt, "TEST4" lname FROM dual UNION all
SELECT To_Date('5/04/2009','mm/dd/yyyy') dt, "TEST5" lname FROM dual UNION all
SELECT To_Date('5/05/2009','mm/dd/yyyy') dt, "TEST6" lname FROM dual UNION ALL
SELECT To_Date('5/31/2009','mm/dd/yyyy') dt, 'TEST7' lname FROM dual UNION all
SELECT To_Date('6/01/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual
)
I would like to write an application that gives you all the end date for months between two dates
for example, if you give the date 9/1/4 and 5/6/9, the output should be
IF I give you the dates 01/04/09 AND 01/06/09, THEN output should beDT LNAME ------------------- 4/30/2009 TEST
as you can see, I want all the end dates of months between two dates by giving the output.DT LNAME ------------------- 4/30/2009 TEST 5/31/2009 TEST7
If I give you 06/05/09 and 05/06/09, and then does so no output because there is no end of month between these two dates.
Similarly, if I give you 30/04/09 and 30/04/09 then output should be 30/04/09 because it is an end of month date
anyone can help to write a query. Thank you very muchJin
Not sure if you need subquery, analytical functions for this.
According to me, which should solve your purpose.WITH data1 AS ( SELECT To_Date('4/30/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual UNION ALL SELECT To_Date('5/01/2009','mm/dd/yyyy') dt, 'TEST2' lname FROM dual UNION all SELECT To_Date('5/02/2009','mm/dd/yyyy') dt, 'TEST3' lname FROM dual UNION all SELECT To_Date('5/03/2009','mm/dd/yyyy') dt, 'TEST4' lname FROM dual UNION all SELECT To_Date('5/04/2009','mm/dd/yyyy') dt, 'TEST5' lname FROM dual UNION all SELECT To_Date('5/05/2009','mm/dd/yyyy') dt, 'TEST6' lname FROM dual UNION ALL SELECT To_Date('5/31/2009','mm/dd/yyyy') dt, 'TEST7' lname FROM dual UNION all SELECT To_Date('6/01/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual ) select distinct last_day(dt) dt,lname from data1 where dt between &start_date and &end_date and last_day(dt) <= &end_date
also, i have another request. how would i do this without using the data i provided. lets say, i tell you, give me alll the months end between two dates using dual in the from clause of a query. how would you do this in a query or pl/sql? thanks again
Can be like that
with data1 as( select &start_date+level-1 dt from dual connect by level <= &end_date-&start_date+1) select distinct last_day(dt) from data1 where dt between &start_date and &end_date and last_day(dt) <= &end_date order by last_day(dt)
See you soon!
BobinPublished by: Buga added query for updated the need
-
How to display each month between the date range
I want a query that gives me the number of months between two dates given for example, if I going January 1, 2009 and April 1, 2009 then I should get on February 1, 2009 and March 1, 2009 in my trips
Thank you very muchSrix wrote:
Thanks for the requestIt is not working do not when the effective date is differs from that in a year i.e start date January 1, 2009 and end date February 1, 2009, that it does not give u then required result
I don't know what you mean? The dates are in the same year.
-
Retrieve the month following the date
Hi people,
How can I get the part of months to a date.
Say, like, I want to get the month part (April = 4) 01/04/2009.
Thanks in advance!Hello
You can get all parts of a DATE using TO_CHAR.
For example, on April 1, 2009SELECT TO_CHAR (SYSDATE, 'Month') FROM dual;
product of the results of this
April
(if you use English) and
SELECT TO_CHAR (SYSDATE, 'MM') FROM dual;
produces this output (VARCHAR2)
04
Maybe you are looking for
-
Firefox 4 is not run on my 64 bit Ubuntu
I've recently updated mmy Firefox 4.0, and now it begins, when I click on it it seems as if it will, but nothing happens. No warning of collision or anything.I use Ubuntu 64 bit
-
Windows used to include the puzzle game Klotski with the Windows Entertainment Pack. Please, where can I download this game for Windows 7?
-
Cancellation xp repair virus damage
I had windows XP repair of viruses that has since been removed, but the damage he did is always there. I used to be able to change the background, when I try to use the Control Panel, display, I get a box greyed, but I can change the color and used t
-
Alienware graphics, compatible video cards, June 2016 amplifier
Is there an official list of compatible video cards that can fit into the amplifier graphics on the site of Dell Alienware? I ordered their Nvidia PNY 980Ti card from the Dell site, but that has been delayed twice now, made me cancel the order. But I
-
8320.msi blackBerry Smartphones blackberry message
I have version 4.3 to office. Whenever the program starts, it asks me to find the file Blackberry 8320.msi as part of the Windows Installer, however, no file doesn't seem to exist. What should I do?