First day/last day of each month
Helloy at - it sql/script to get the first day/last day of each month.new to bi do not know the syntax
If a point on the link to get these things will be highly appreciated
Hello
I suggest that you go through the following link
(1) http://oracle.ittoolbox.com/groups/technical-functional/oracle-bi-l/obiee-date-comparison-1726677#M1729534
Toget first/last day of the month
(2) http://www.obinotes.com/2010/02/tip-to-get-firstday-lastday.html
New to OBIEE---> http://obiee101.blogspot.com/2009/07/obiee-how-to-get-started.html
Thank you
Saichand.V
Tags: Business Intelligence
Similar Questions
-
use to insert the last day of each month
Hi, I wrote this code but it did not insert the 20 December and it is January 1, and next time running is 31 January... I would like to work to make this insert every last day of each month...
I don't know if it's because I assigned the date 31-10... In November it's just but December has not...begin sys.dbms_job.submit(job => :job, what => 'INSERT INTO hisrtu SELECT rtunum, linked, dbchkd, chaqty, dbvald, ctrltr, meaadj, qtyrtu, month, year, entity, rtunam FROM qtyrtu;', next_date => to_date('31-10-2010 01:00:03', 'dd-mm-yyyy hh24:mi:ss'), interval => 'SYSDATE +30'); commit; end; /
Best regards, hope you can help me.
I use oracle 9iHello
If you want the job to run at 02:00 the last day of the next month, then the desired argument is:
interval => 'ADD_MONTHS (TRUNC (SYSDATE, ''MONTH''), 2) - (22 / 24)'
In other words, if she finishes running at 02:30 on 31 January, then
TRUNC (SYSDATE, 'MONTH') will be at 00:00:00 January 1
ADD_MONTHS (TRUNC (SYSDATE, 'MONTH'), 1) will be March 1st at 00:00:00
ADD_MONTHS (TRUNC (SYSDATE, 'MONTH'), - 1) (22 / 24) will be 22 hours earlier, i.e. 02:00 on the last day of February.logandro wrote:
I don't know if it's because I assigned the date 31-10... In November it's just but December has not...Do you mean this line?
next_date-online to_date (October 31, 2010 01:00:03 ',' dd-mm-yyyy hh24:mi:ss'),
I don't think that's a problem. The next_date specifies only when it work baptisms. I guess he ran on October 31; you said it was running well on 30 November, 30 days after that. Something has to happen after November 30.
Note that the interval argument is relative when the task completes. If a task takes 30 minutes to run, then
interval => 'SYSDATE +30'
means that, if it turns to
01:00:03 October 31, then it will run again about
01:30:03 November 30, around
02:00:03 on December 30.
02:30:03 January 29 and so on. If your business does that for a few seconds, it won't matter much.If you decide to use LAST_DAY, don't forget not that the hours-minutes-seconds referring LAST_DAY are the same as those of his argument.
-
Hi friends here is the querry I wrote to display every first day of the month, but there is something wrong in it... Help me...
create or replace procedure minmax is
cursor minmax_cur is
Select min (hiredate), max in emp (hiredate);
number of v_minmonths;
number of v_maxmonths;
number of v_minyears;
number of v_maxyears;
x date of publication;
date of y;
Start
Open minmax_cur;
extraction minmax_cur
x, y;
v_minmonths: = extraction (x months);
v_minyears: = extraction (year x);
While (x, y) loop
because me in 1... v_minmonths loop
If (v_minmonths < 12) then
v_minmonths: = v_minmonths + 1;
x: = x + 28.
dbms_output.put_line(v_minmonths ||) '/' || '01'. '/' ||
v_minyears);
on the other
v_minmonths: = 0;
v_minyears: = v_minyears + 1;
x: = x + 28.
end if;
end loop;
end loop;
minMax end;
and the results are
01/01/1981
01/02/1981
01/03/1981
..................
.........---
01/04/1987
01/05/1987
01/06/1987
01/07/1987
01/08/1987
01/09/1987
01/10/1987
01/11/1987 the problem is max (hiredate) is 5/23/1987...it must show up to 01/05/1987...
I get a few more months...
-
Query or logic to find several days through each month.
Dear friends,
I need your help to solve this problem.
We have a now where we have to pay compensation to the employees based on their number of working days.
Say, for example, if an employee has worked since March 3, 2012-April 5, 2012.
We have a fixed value for a month 300 dirhams. But the number of days on s March 31 and number of days in the month of April are 30.
So by compensation daily for March day would be 300/31 and April would be 300/30.
We are looking for a logical opr query that calcluates first right number of days in each month (per month) and then calculate as below
Number of working days in the month of March is 31-3 + 1 = 29
Compensation of A1 = (300 * 29) / 31
Number of working days in the month of April is 5 (must also find logical I guess)
Allowance for A2 = (300 * 5) / 30
Then A1 + A2.
(E) would be the total quota when the number of months in all.
Please guys any help would be greatly appricated.
RJust a follow-up ;-)
Note that you can almost get what you want with standard MONTHS_BETWEEN function [url http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions102.htm#i78039].
But notice this quote from the documentation:>
If date1 and date2 are the same days of the month or the last two days of the month, the result is always an integer. Otherwise the Oracle database calculates the fractional part of the result based on a month of 31 days and consider the time difference components date1 and date2.
>It will always use one even if 31 days a month has fewer days.
Then you could also implement the logic of my previous answer as your own function months_between implementation:
create or replace function my_months_between ( p_todate date , p_fromdate date ) return number is begin return ((extract(day from last_day(p_fromdate))-extract(day from p_fromdate)+1) / extract(day from last_day(p_fromdate))) + (months_between(trunc(p_todate-1,'MM'),trunc(p_fromdate,'MM'))-1) + (extract(day from p_todate-1) / extract(day from last_day(p_todate-1))); end my_months_between; /
I changed it to make it "compatible" with the standard function that it calculates up to but not including the parameter to date (which is correct when you are considering dates with time included, but I guess in your case, you have just date values.)
Then, you can compare the results of the standard months_between with the new my_months_between:
(Note that I have call the functions with the d2 + 1 to give the desired result of inclusion and to this day in the calculation).SQL> with testdata as ( 2 select date '2012-03-03' as d1, date '2012-04-05' as d2 from dual union all 3 select date '2012-02-03' as d1, date '2012-05-02' as d2 from dual union all 4 select date '2012-03-03' as d1, date '2012-03-10' as d2 from dual union all 5 select date '2012-03-01' as d1, date '2012-07-31' as d2 from dual union all 6 select date '2012-02-01' as d1, date '2012-03-01' as d2 from dual union all 7 select date '2012-01-01' as d1, date '2012-03-25' as d2 from dual 8 ) 9 -- 10 -- end of test data -- 11 -- 12 select months_between(d2+1, d1) std_months 13 , 300 * months_between(d2+1, d1) std_allowance 14 , my_months_between(d2+1, d1) my_months 15 , 300 * my_months_between(d2+1, d1) my_allowance 16 from testdata 17 / STD_MONTHS STD_ALLOWANCE MY_MONTHS MY_ALLOWANCE ---------- ------------- ---------- ------------ 1.09677419 329.032258 1.10215054 330.645161 3 900 2.99555061 898.665184 .258064516 77.4193548 .258064516 77.4193548 5 1500 5 1500 1.03225806 309.677419 1.03225806 309.677419 2.80645161 841.935484 2.80645161 841.935484 6 rows selected.
For a large part of the data, both give the same result, especially when the two dates are in month of 31 days.
To work from ' 2012-03-03' to '' 2012-04-05 standard service gives too little because it uses always 31 days, while my_months_between uses 30 days of April."But note working from '' 2012-02-03 to 2012 - 05 - 02. He jumped 2 days in February and has worked 2 days in May - the standard function concludes he works precisely 3 months.
But my_months_between computes fraction 27/29 months in February, then March and April like 2 months, and then the fraction 2/31 months in May - which gives a total of 2.99555061 instead of 3 months.Just something to be aware of ;-)
-
How to calculate the first day of the month following in BI Publisher
I need to be able to calculate the first day of the month of a date field in a BI Publisher model. The field name is COL_CLM_180 and contains a date in the format "YYYY-MM-DD". I have found so far any documentation that still gives me an idea of what to do.
Any help or advice would be appreciated
Hi - thank you very much for your help. Your last answer got me going in the right direction and I indeed was dense. I don't know why I don't think to the calculation in the original query. I put the statement: TRUNC (ADD_MONTHS(A.COL_CLM_180,1), 'MM') in a column in the query of conduct and it has worked flawlessly. Thank you - thank you - thank you.
-
Hello
Can someone help me to write a code when a random day is given a month, that the day should change automatically
in the first day of a month.Can you give an example?
Do you mean the last day of the month for a random date?
Then you can simply use builltin Oracle LAST_DAY function:SQL> select sysdate from dual 2 union 3 select last_day(sysdate) from dual; SYSDATE ------------------- 03-05-2012 18:17:04 31-05-2012 18:17:04
-
First day of the month between 08:00 and 18:30
DB version: 10.2.0.4
Due to the nature of our the first working day of each month (like today 1 MS), the DB will be very busy.
We execute a proc purge planned Windows Scheduler every 5 minutes every day.
But the first day of every month (like today 1 MS), if it's a day of the week (Monday to Friday) we do not want this proc running between 08:00 and for dinner from 18:30.
So, I thought including the logic in the procedure itself.
How can I implement this?
Edited by: user872043, Sep 1 2010 08:48Here is an example of using DBMS_SCHEDULER which should meet your needs:
Create schedules
BEGIN DBMS_SCHEDULER.CREATE_SCHEDULE ( schedule_name => 'every_5_schedule' , repeat_interval => 'FREQ=MINUTELY; BYMONTHDAY=2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31; INTERVAL=5; BYSECOND=0' , comments => 'Schedule to run every 5 minutes' ); DBMS_SCHEDULER.CREATE_SCHEDULE ( schedule_name => 'busy_hourly_schedule' , repeat_interval => 'FREQ=MINUTELY; BYMONTHDAY=1; BYHOUR=0,1,2,3,4,5,6,7,19,20,21,22,23; INTERVAL=5;' , comments => 'Schedule to run every 5 minutes except certain hours on the first of the month' ); DBMS_SCHEDULER.CREATE_SCHEDULE ( schedule_name => 'busy_6pm_schedule' , repeat_interval => 'FREQ=MINUTELY; BYMONTHDAY=1; BYHOUR=18; BYMINUTE=30,35,40,45,50,55' , comments => 'Schedule to run every 5 minutes from 6:30 - 7' ); END; /
There are three lists.
every_5_schedule - runs every 5 minutes for all the days that are not on the first day of the month
busy_hourly_schedule - runs every 5 minutes for the acceptable hours on the first day of the month
busy_6pm_schedule - retrieves the half hour from 6:30 - 7 on the first day of the month.Then, create your business:
Job creation
BEGIN DBMS_SCHEDULER.CREATE_JOB ( job_name => 'YOUR JOB' , job_type => 'PLSQL_BLOCK' , job_action =>'BEGIN YOURPROC; END;' , repeat_interval => 'EVERY_5_SCHEDULE, BUSY_HOURLY_SCHEDULE, BUSY_6PM_SCHEDULE' , enabled => TRUE , comments => 'Some comments' ); END; /
HTH!
-
query for the first day of the month
Hi all
How to get the first day of the month in the sql query.
SQL> select trunc(sysdate,'mm') first_day from dual; FIRST_DAY --------- 01-AUG-15 SQL> select trunc(sysdate,'month') first_day from dual; FIRST_DAY --------- 01-AUG-15 SQL> select trunc(sysdate,'mon') first_day from dual; FIRST_DAY --------- 01-AUG-15 SQL>
-
How to find the first day of the month following two years one year from now?
Hello
I need to find the first day of the month following two years ago, based on the current date.
For example: If today is the 31/08/2015 so I need to find the date range between 31/08/2015 and on 09/01/2013. How can I write an SQL which allows to automate this calculation instead of hard-coding the values. Please do help me out with this so that I can build the SQL that can produce the desired result.
Thank you
Dhilip
find the start of the month - 2 years in advance, early - 2 years + 1 months in advance and go back 1
Select trunc (add_months(sysdate,24), 'MM'), trunc (add_months(sysdate,25), 'MM') - 1 double;
-
first day of the month and time
Hello
Using oracle 11.2.0.3
A table with a column date
sample opening time data 04/08/2014-08:30 one single column, another column start date 04/02/2014
Want to have a sql that will go through an opening time table set on the first day of the month as well as existing time
for example expect times to be
04/01/2014 08:30
Code below will give the first day of the month
What is the best way to achieve this-date data type columns.
{code}
Select trunc(start_time,'MM))
of customer_hours ch
{code}
Select
SYSDATE - trunc (sysdate) + trunc (sysdate, 'MM')
of the double
resp.
Select
start_time - trunc (start_time) + trunc (start_time, 'MM')
of the double
-
for the 25th day of each month in Date function
Dear all,
I want to want to get the 25th day of each month
as.
Select sysdate from dua.
ConcerningSQL> select trunc(sysdate,'MM')+24 "Day" from dual; Day --------- 25-MAY-13
-
Published by: user12957777 on May 23, 2012 21:12How to find the first day of the month if the month format is like TO_CHAR(SYSDATE,'YYYYMM') Sanjay
There is no 'day' in this date format.
What you trying to do? What do you expect the result to look like?
Are you wanting to set a date for the first day of the month and year of your example?
SELECT TO_DATE(TO_CHAR(SYSDATE,'YYYYMM') || '01', 'YYYYMMDD') FROM DUAL;
-
How can I update the column 1st day of each month
Hello
I have an Emp table with the following columns
now it has the following features,1.Emp_name varchar2(50), 2.Days number(3).
Now I need to update the column 'Days' 20 for emp_name all whenever the date is the first day of the monthEmp_name Days Mishra 11 David 15 Raju 18
IE June 1, 2012 July 1, 2012 and so on.
How can we do?
can someone help me.
Thank you.Look for the DBMS_SCHEDULER package.
Kind regards
-
find the first day of the month
Hello...
can u pls let me know how to find the first day of the month, if the number of months (for ex - OCT-10) is passed as input
Kind regardsI'm not sure that there is a function called FIRST_DAY().
SQL> SELECT first_day (SYSDATE) 2 FROM DUAL; SELECT first_day (SYSDATE) * ERROR at line 1: ORA-00904: "FIRST_DAY": invalid identifier SQL> SELECT TRUNC (SYSDATE, 'month') 2 FROM DUAL; TRUNC(SYS --------- 01-DEC-08 SQL>
I hope this helps.
Kind regards
Joice -
Select the last record of each month
Hello
to select the last docnumber and qty of every month
Structure
Name Null? Type
------------------------------- -------- ----
PRODUCTCODE NUMBER
NUMBER NUMBER
DATE OF PLANFORMONTH
NUMBER OF CLEXPECTEDQTY
NUMBER OF CLCONFIRMQTY
NUMBER OF CLFGBUFFERQTY
NUMBER OF CLTOTPRINTBUFFER
in this select query if I take the sum he required all records where, as I want the last record of each month
SELECT productcode docnumber MAX (Number), planformonth, SUM (clexpectedqty) clexpectedqty (planformonth) MAX.
SUM (clconfirmqty) clconfirmqty, SUM (clfgbufferqty) clfgbufferqty, cltotprintbuffer OF FGSALESPLAN of the SUM (cltotprintbuffer)
GROUP BY productcode, (planformonth)
Sandy
Hello
Thanks its working now the code is written as below:
SELECT * FROM
(SELECT
e.*,
ROW_NUMBER() OVER (partition by PRODUCTCODE by DOCNUMBER DESC order) r
Of
E FGSALESPLAN)
WHERE r = 1 AND
entryvalid = 'Y '.
order by Number
Sandy
Maybe you are looking for
-
Satellite L350D-110 - BSOD on Windows XP
Hello I create a CD of XP (SP2) to nLite with the Sata driver. The SATA in the BIOS mode is AHCI Version of the display driver 8.479.1.4 Installation ist from, then I get a blue screen. What I've done wrong? Help, please. CUsinoh
-
Satellite Pro 6100: BSOD after use of the 6000 SP recovery CD
My 6000 Pro Satellite recently bitten the dust after several years of daily use. I just bought a used SP6100, after which I tried to use my SP6000 product recovery CD to do a reformat. Since when I Stop (obviously common) * 0x0000007B (0xF9680640, 0
-
Live cam update a graph changed in a Subvi
Hello A quick explanation of the situation: I have a program that allows you to acquire data from a CCD camera. This program is a stand-alone or as a TCP server for another piece of software. I would write the server TCP as a Subvi part, in return, s
-
HP Mini 110: upgrade for computer laptop windows xp
Is it possible to upgrade a laptop of HP Mini 110 10 Windows or something else?
-
WINDOWS 7 HOME PREMIUM - PROBLEMS PLAY RPG
Hello guys - I'm a girl, so please bear with my tiny no mind technique. I like RPG and download them on Aldorlea and Blossomsoft to name a few. Have Windows 7 now and whenever I try to play the games I get a black screen to the icon (I can hear the