Calculation of the number of months
Hi guys,.
How to calculate the number of months between two dates
Opening date: 20/02/2014
Closing date: 20/03/2015
Terms of months: 13
How I get the year and subtract and multiply by 12 and then add it to the difference of the month? Sorry that I am not well versed in the scripts.
Thanks in advance.
In this way, you have provided the example. You can change the constant string to the necessary code to get the value of a field. You can add additional to prevent code by using the code until the two fields have a non-null value.
Tags: Acrobat
Similar Questions
-
REQ: script to calculate the number of months
Looking for a script that will calculate the number of months between 2 dates (to 2 decimal points)
or if there is a way to make a calculation of the number of months
for example: if I go to google and say 75 days - months, it returns a value of 2.46
That's what I'm looking for
If anyone can help?
with a calculation of date or number calculation?
I tried # days / 365 x 12 but there is no decimal places. right guard rounded up/down
As mentioned in a month, the days are not constant throughout the year and change formula 28-31 days. How are you calculating the decimal value of the month?
A year has 365 days, if she did then there would be no need for leap years and centuries jump.
Calculation of a variable with the result of a calculation method is set to decimal.
cDateFormat = "d-mmm-yyyy";
var cStartDate = "January 1, 2000;
var oStartDate = util.scand (cDateFormat, cStartDate);
oStartDate.setHours (0, 0, 0, 000);
var cEndDate = "January 15, 2000;
var oEndDate = util.scand (cDateFormat, cEndDate);
oEndDate.setHours (0, 0, 0, 000);
nDiff var = oEndDate.getTime () - oStartDate.getTime ();
Console.println ("end date:" + cEndDate);
Console.println ("start date:"+ cStartDate ");
Console.println ("difference in milliseconds:" + nDiff);
Console.println ("difference in seconds:" + nDiff/1000);
Console.println ("difference in minutes:" + nDiff / (1000 * 60));
Console.println ("difference in hours:" + nDiff / (1000 * 60 * 60));
Console.println ("difference in days:" + nDiff / (1000 * 60 * 60 * 24));
Console.println ("difference in weeks:" + nDiff / (1000 * 60 * 60 * 24 * 7));
Console.println ("difference over the years:" + nDiff / (1000 * 60 * 60 * 24 * 365.2524));
Console.println ("difference in months:" + nDiff / ((1000 * 60 * 60 * 24 * 365.2524) / 12)); 12 months in a year;End date: January 15, 2000
Start date: January 1, 2000
Difference in milliseconds: 1209600000
Difference in seconds: 1209600
Difference in minutes: 20160
Difference in hours: 336
Difference in days: 14
Difference of weeks: 2
Difference in years: 0.0383296591617194
Difference in months: 0.45995590994063273Several turncate the decimal values scirpts because keeping them may not meet the need of specific calculation. You know that there are methods to roud until the next iniger, round.5 to the top and turnacate to the lower intiger.
According to the date of departure, the values may be different:
For a start date of February 1, 2000, 75 days would be 1,810 months but for a start date of 1 February 2001 75 days becomes 1,838 since the number of days of changes of February 29 to 28 and the number of days for the month of fractions varies from 26 to 27.
-
Count of the number of months with unpaid for the last six months
Hello
I now table to store the daily presence of each employee
ATTENDANCESHEET
EMPID
PAYROLLDATE
UNPAID
1
10/01/2013
6
1
10/02/2013
2
1
11/01/2013
0
1
11/02/2013
0
1
12/01/2013
0
1
12/02/2013
0
1
01/01/2014
0
1
01/02/2014
0
1
02/01/2014
0
1
02/02/2014
0
1
03/01/2014
45
1
03/02/2014
0
2
03/01/2014
0
2
03/02/2014
0
I want to get the number of months used unpaid in the past 6 months (excluding the current).
If the month of payroll, I'm in treatment is 4, 2014, I spend 4 as payrollmonth and 2014 as payroll year
The application must check the latest 6 month data and number of months for which there is any unpaid value
In the case above for month 4, 2014, the power required is
EmpID
County
1
2
2
0
I use oracle 10g
EXAMPLES OF DATA
create the table attendancesheet as
(
Select 1 as empid, to_date (January 10, 2013 ',' DD/MM/YYYY ') as payrolldate, 6 paid by union double all the
Select 1 as empid, to_date (10 February 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the
Select 1 as empid, to_date (January 11, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the
Select 1 as empid, to_date (February 11, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the
Select 1 as empid, to_date (12 January 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the
Select 1 as empid, to_date (February 12, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the
Select 1 as empid, to_date (1 January 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the
Select 1 as empid, to_date (February 1, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the
Select 1 as empid, to_date (January 2, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the
Select 1 as empid, to_date (February 2, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the
Select 1 as empid, to_date (3 January 2014 ',' DD/MM/YYYY ') as payrolldate, 45 paid by union double all the
Select 1 as empid, to_date (3 February 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the
Select 2 as empid, to_date (3 January 2014 ',' DD/MM/YYYY ') as payrolldate, 0 as default all the double union
Select 2 as empid, to_date (3 February 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid double
);
Help, please
Hello
So, you want to count the distinct months for 6 months before (not included) the given month; is this fair?
Here's one way:
VARIABLE month VARCHAR2 (2)
Year VARIABLE VARCHAR2 (4)
EXEC: months: = '4';
EXEC: year: "2014"; =
WITH got_end_date AS
(
SELECT TO_DATE (: month |) '/' || : year
, ' MM/YYYY ".
) AS end_date
OF the double
)
SELECT a.empid
, COUNT (DISTINCT
CASE
WHEN a.unpaid > 0
THEN TRUNC (a.payrolldate, 'MONTH')
END
), Cnt
Of attendancesheet one
JOIN e-got_end_date WE a.payrolldate > = ADD_MONTHS (e.end_date-6)
AND a.payrolldate< > >
GROUP BY a.empid
ORDER BY a.empid
;
If you use a WHERE clause to exclude the lines with some outstanding = 0 (or unpaid is NULL), then you would get no output for employees like empid = 2 in this example. A WHERE clause ignores an entire line, so I used an expression BOX just a value.
-
Select the number of months (NULL and non-null separated)
-Table_1
-------------
create table_1
(
Arrival_Date DATE
Counter_seq number (*) not null,
Exclusion_type varchar2 (10)
)
-INSERTION
-------------
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 1,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 2, 'PAW');
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 3, 'HAN');
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 4,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 5,"LUG");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 6, 'HAN');
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 7,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 8, 'PAW');
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 9, 'HAN');
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 10,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 11, 'PAW');
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 12, 'HAN');
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 13,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 14,"LUG");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 15,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 16,"LUG");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 17,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 18,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 19, 'HAN');
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 20,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 21,"LUG");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 22,"LUG");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 23,"HAN");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 24,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 25,");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-DEC-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 26,"LUG");
INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 27,");
-SELECT THE NUMBER OF MONTHS
--------------------------------------
SELECT EXCLUSION_TYPE,
County (decode (to_char (ARRIVAL_DATE, 'MON-YYYY'), "DEC-2009", COUNTER_SEQ ")) dec09,.
County (decode (to_char (ARRIVAL_DATE, ' MON-YYYY ""), "JAN-2010", COUNTER_SEQ ")) Jan10.
County (decode (to_char (ARRIVAL_DATE, 'MON-YYYY'), ' Feb-2010 ", COUNTER_SEQ")) Feb10
FROM TABLE_1
EXCLUSION_TYPE GROUP;
-CHOOSE IT ABOVE RETURENS: -.
------------------------------------------------
EXCLUSION_ DEC09 JAN10 FEV10
4 4 4
0 3 4 LEG
HAN 3 2 0
My question is, I need to select a month ruturning one row of NULL values and a line of values not null. Like that so all right: -.
EXCLUSION_ DEC09 JAN10 FEV10
Exclusion_Type 4 4 4 NULL
Exclusion_Type Not null 3 5 4
The ideas people?
Published by: Deeds_2001 on November 16, 2010 12:47 AMSQL> SELECT DECODE(exclusion_type,NULL,'NULL','NOT NULL') exclusion_type, 2 COUNT(DECODE(TO_CHAR(arrival_date, 'MON-YYYY'), 'DEC-2009', counter_seq)) Dec09, 3 COUNT(DECODE(TO_CHAR(arrival_date, 'MON-YYYY'), 'JAN-2010', counter_seq)) Jan10, 4 COUNT(DECODE(TO_CHAR(arrival_date, 'MON-YYYY'), 'FEB-2010', counter_seq)) Feb10 5 FROM table_1 6 GROUP BY DECODE(exclusion_type,NULL,'NULL','NOT NULL'); EXCLUSIO DEC09 JAN10 FEB10 -------- ---------- ---------- ---------- NULL 4 4 4 NOT NULL 3 5 4 SQL>
-
Get the number of month, week and day between 2 dates
Hi all
Is it possible to display the number of months, weeks and days between 2 dates? by using only the SQL or PL/SQL...
Entry:
Date: October 1, 2010
Date: October 19, 2010
I want output like below (assuming starts the week from Monday to Sunday in oracle).
October 1, 2010-(since it's in the middle of the week)
October 2, 2010-(since it's in the middle of the week)
October 3, 2010-(since it's in the middle of the week)
40. (4 Oct-10 Oct falls into the 40th week of the year)
41. (11 Oct-17 Oct falls into the 41st week of the year)
October 18, 2010-(since it's in the middle of the week)
October 19, 2010-(since it's in the middle of the week)
Note: If there is a month between the date, the number of the month should be displayed.
End of the month, the remaining date included with a full week, then the week of the year number should
displayed. After posting the week, remaining dates should be displayed as it is...
Appreciate your help...
Thank you.
Fox.You mean something like this...
SQL> ed Wrote file afiedt.buf 1 WITH t AS (select date '2010-09-27' as fdate, date '2010-11-21' as tdate from dual) 2 -- 3 -- END OF TEST DATA 4 -- 5 select dt2 6 from ( 7 select dt, 8 case when days_of_mn = days_in_month then 'Whole: '||to_char(dt,'Month') 9 when days_of_wk = 7 then 'Week: '||to_char(dt,'fmWW') 10 else to_char(dt, 'DD-fmMonth-YYYY') 11 end as dt2 12 ,row_number() over (partition by 13 case when days_of_mn = days_in_month then to_char(dt,'Month') 14 when days_of_wk = 7 then 'Week: '||to_char(dt,'fmWW') 15 else to_char(dt, 'DD-fmMonth-YYYY') 16 end order by dt) as rn 17 from ( 18 select dt, wk, mn, days_in_month 19 ,count(*) over (partition by wk) as days_of_wk 20 ,count(*) over (partition by mn) as days_of_mn 21 from ( 22 select fdate+rownum-1 as dt 23 ,to_number(to_char(fdate+rownum-1,'fmWW')) as wk 24 ,to_number(to_char(fdate+rownum-1,'fmMM')) as mn 25 ,to_number(to_char(last_day(fdate+rownum-1),'fmDD')) as days_in_month 26 from t 27 connect by rownum <= tdate-fdate+1 28 ) 29 ) 30 ) x 31 where rn = 1 32* order by dt SQL> / DT2 ----------------- 27-September-2010 28-September-2010 29-September-2010 30-September-2010 Whole: October Week: 44 Week: 45 Week: 46 19-November-2010 20-November-2010 21-November-2010 11 rows selected. SQL>
-
is there an easy way to get the number of months in a year in a date range?
Hi, experts, I am a newbie.
are there any easy ways to get the number of months in a year in a date range?
I would like to write a user-defined function.
the input parameters are startdate, enddate, year
the output is a number, not a month.
for example, case 1
StartDate = 01032009 (DDMMYYYY)
end date = 28022010 (DDMMYYYY)
If the year 2009, the output is 10
If the year = 2010, the output is 2
case 2:
StartDate = 10032009 (DDMMYYYY)
end date = 15032010 (DDMMYYYY)
If the year 2009, the output is 10
If the year = 2010, the output is 3
Thank you very much!Hello
You can (also) try this:
SQL> with s as ( 2 ------------ Sample data ------------- 3 select to_date('01032009','ddmmyyyy') startdt, to_date('28022010','ddmmyyyy') enddt, 2009 yr from dual 4 union all 5 select to_date('01032009','ddmmyyyy') startdt, to_date('28022010','ddmmyyyy') enddt, 2010 yr from dual 6 union all 7 select to_date('10032009','ddmmyyyy') startdt, to_date('15032010','ddmmyyyy') enddt, 2009 yr from dual 8 union all 9 select to_date('10032009','ddmmyyyy') startdt, to_date('15032010','ddmmyyyy') enddt, 2010 yr from dual 10 ------------ Sample data ------------- 11 ) 12 select startdt, enddt, yr, 13 months_between( 14 least(trunc(to_date(yr+1,'yyyy'),'year') , add_months(trunc(enddt,'month'),1)) 15 , greatest(trunc(to_date(yr,'yyyy'),'year') , trunc(startdt,'month')) 16 ) nbmonths 17 from s; STARTDT ENDDT YR NBMONTHS ---------- ---------- ---------- ---------- 01/03/2009 28/02/2010 2009 10 01/03/2009 28/02/2010 2010 2 10/03/2009 15/03/2010 2009 10 10/03/2009 15/03/2010 2010 3
It's pretty simple. (no connection with, without functions SQL only integrated multicast, etc...)
-
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
-
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 -
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
-
Calculation of the number of fails?
Hello
I have a report that includes:
The course ID, number of students, score average, brand Maximum, standard deviation, Minimum Mark.
Each course has several students on this and there is currently a line by which is what I want to keep.
I want to be able to add another column that gives, for each course, the number of students who have failed (the brand is less than 40)
and another column that tells me that the percentage of the total on the course that failed
Does anyone have suggestions of how best to do it?
The formulas I have used to date are:
MIN (Mark) OVER (PARTITION BY ID of course)
Max (Mark) OVER (PARTITION BY ID of course)
AVG (Mark) OVER (PARTITION BY ID of course)
StdDev (Mark) OVER (PARTITION BY ID of course)
Thank you in anticipation
SueHello
I know not why you use the analytical functions with a partition when you want just a single line by course_id. Count (student_id), min (mark), max (mark), avg (mark) and stddev (mark) should give you what you need.
To calculate that the number has not then you need calculation as;
Count (case when Mark< 40="" then="" student_id="">
and the percentage to help
Count (case when Mark< 40="" then="" student_id="" end)="" *="">
Rod West
-
Calculation of the number of rows in the query object
Hi all
I have a question:
Is there a way to get the number of rows in a query object without running it twice?
I need this for a calculation of total pages.
I can't do something like:
"SELECT COUNT (e) FROM employee e"
because I have a WHERE clause in my expression.
Thank youI don't think I've had this a simple that you would like to, but I was able to reuse the same query named to account real pagination queries request.
I defined a named query:
@NamedQuery(name = "Employee.findByNames", query = "select e from Employee e WHERE e.firstName LIKE :FNAME AND e.lastName LIKE :LNAME AND e.gender = :GENDER ORDER BY e.lastName, e.firstName")
Now in the app, I can create an instance of the query for this named query and fill in the parameters using the:
Query query = em.createNamedQuery("Employee.findByNames"); query.setParameter("FNAME", "%"); query.setParameter("LNAME", "%"); query.setParameter("GENDER", "M");
If I run this query I get all the lines, but instead, I'd like to create an account using the underlying native API query
ReadAllQuery raq = JpaHelper.getReadAllQuery(query); ReportQuery reportQuery = new ReportQuery(raq.getReferenceClass(), new ExpressionBuilder()); reportQuery.setSelectionCriteria(raq.getSelectionCriteria()); reportQuery.setOrderByExpressions(raq.getOrderByExpressions()); reportQuery.setShouldReturnSingleValue(true); reportQuery.addCount(); Query countQuery = JpaHelper.createQuery(reportQuery, em); countQuery.setParameter("FNAME", "%"); countQuery.setParameter("LNAME", "%"); countQuery.setParameter("GENDER", "M"); int count = ((Number)countQuery.getSingleResult()).intValue();
Then, for each page of entities wanted the original query is executed as:
query.setFirstResult(0); query.setMaxResults(5); List
emps = query.getResultList(); Doug
-
Calculation of the number of sessions of relaxation JTAPI
Assumea Trigger 1111 5 sessions and the Group of call control, say 20 ports as well as the Application as the session 20.
If the part of the script requests a call-redirect to another trigger 2222 - the number of sessions to 1111 will decrease by one after the call-forwarding? (Note that it does not call a subflow but a redirect to appeal to another trigger)
Thank you!
Yes, the number of sessions for 1111 decreases by one after the call forwarding.
-
Perform calculations using the number of records
I'm working on a formula that calculates an employee vacation time. The employee of begins with a static balance, say 120. The employee can enter their vacation time, as they take. They cannot get it in increments of 8 hours or 4 hours, for each record in the database will reflect 8 or 4 hours. I want to be able to view a current balance for the employee. So if the employee connects and takes a week of vacation, they will have to enter 5 records with 8 hours each. How to calculate this to get the desired balance of 80? I'm not very fluent with calculations in the CF, but think that it must involve the Recordset. It's probably very easy, but I am confused.
Any help would be great! Also if I didn't explain it properly, let me know and I'll try to provide more details.Jatrix wrote:
>
> Any help would be great! Also if I didn't explain it properly, let me know
> and I'll try to provide more details.
>Well, you * could * simply add all the fields "vactaionTime" of each
record in the Recordset. I.E.
#totalVac #. But it's really much easier to do with some simple SQL codes.
SELECT empID, sum (vacTime) AS totalVacTime
FROM EmployeeTable
GROUP BY empID
#empID # #totalVacTime #.
-
Calculation of the number of rows between two rows
Hello
For a query I want to connect two tables with an outer join, and the external joined table instead of display NULL values display the value of the last row containg data. I try it using the LAG function, but I need the number of lines from which to extract the data to be dynamic, as the gap between the current line (NULL) and the last line displays data.
For example:
SELECT NVL (fadd.deprn_reserve,
LAG (fadd.deprn_reserve, "XXX") OVER (ORDER BY fadp.period_counter)
),
fadp.period_counter
OF fa_deprn_detail fadd, fa_deprn_periods naturally
WHERE fadd.period_counter (+) = fadp.period_counter
, where 'fadd' contains amounts and accounting periods 'naturally '. For example, there would be a balance in NOV - 08 with the next transaction is made in MAY - 09. Periods DEC-08 Apr-09 all shall display the balance of NOV - 08. The "XXX" would be the difference of the position of each line to the ' NOV-08' containing the amount to use.»
Is there a way to calculate the difference in positions of line like this, or this approach is not feasible?
ConcerningHello
I think LAST_VALUE is better for this task.
As Salim said, it is always useful to post a small example of data and the results desired from these data. Your version of Oracle can be important.
Using the table scott.emp, here is an example of using LAST_VALUE:
SELECT ename , comm , LAST_VALUE (comm IGNORE NULLS) OVER ( ORDER BY ename ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) AS prev_comm FROM scott.emp ORDER BY ename ;
Output:
ENAME COMM PREV_COMM ---------- ---------- ---------- ADAMS ALLEN 300 BLAKE 300 CLARK 300 FORD 300 JAMES 300 JONES 300 KING 300 MARTIN 1400 300 MILLER 1400 SCOTT 1400 SMITH 1400 TURNER 0 1400 WARD 500 0
-
How to convert the number in months?
Hi friends
I have data in the table like this
Month
01
02
03
04
I want to convert in months. e, g
01 if it should appear January
02 if it should appear February
What is the SQL query? Help, please.
rgads
with
months as
(by selecting '01' mnth throughout double Union
Select '02' of any double union
Select '03' in double union
Select '04' double
)
Select mnth, to_char (to_date (mnth, 'mm'), 'Month') mnth_name
of the month
MNTH MNTH_NAME 01 January 02 February 03 March 04 April Concerning
Etbin
misread - must be a number
with
months as
(select 1 month of all the double union)
Select 2 Union double all the
Select 3 in all the double union
Select 4 double
)
Select mnth, to_char (to_date (to_char (mnth), 'mm'), 'Month') mnth_name
of the month
Maybe you are looking for
-
Satellite A60: charging problem
Hey,.I have a toshiba satellite A60 laptop. My laptop has 2 years. After that I used my laptop in battery mode, it fell because the battery was empty. When I plugged it on the net, the battery led flashed amber for less than a second and went back. T
-
Error code: don't have 0x2B33 KB960082
The KB above is 'updating security for SQL Server 2000 SP4'. Automatic updates successfully downloads and installs, but after a reboot, the Update icon reappears I always ask to install. Belarc Advisor lists this as lacking KB, it lists as "a securit
-
Hi all first I use hp pavilion g series so I checked today if my laptop can run GTA IV but his failure due to Dedicated video RAM This means my laptop cant run this game cause my video card is low?
-
performing backup error Code: 0x80071AC3 need to format NTFS
try to backup Iomega desktop drive usb2 hard format system asked to continue format does not have NTFS only ex FAT Error code now 0x80071AC3 cannot continue with the backup I added an iomega desktop hard drive, the system asked me format may only nee
-
In fact, one of my clients has two Cisco 5508 wireless LAN controllers installed in a site and back up and running now. one of them running software version 7.4 and the other running software version 7.6. Each of them works as a stand-alone controlle