How to calculate a week & Month in given date range (not for sele-options)
Hi ,
I have defined 2 date parameters in sel-screen (Plz remember that date variable are not a SELECT-OPTIONS). Now i want ot display week nos & monts in output.
Ex: date1: 20080101 & date2: 20080229. then
weeks : 1, 2, 3,---9.
months: jan-08, feb-08.
Plz help me with block of code or any FM.
Regards,
Hi Srikanth,
The FM HR_99S_INTERVAL_BETWEEN_DATES is doesn't existing, but there is a fm HR_MX_INTERVAL_BETWEEN_DATES but it returns no of Years & Days.
But i found some FM which r returns no of months for given date range. but my requirement is, want to display the month no bw 1 to 12. (ex: dat1=15-03-2008 & dat2= 01-06-2008 then in month fields 03,04,05 & 06. ).
Plz help me on this.
-Regards.
Similar Messages
-
How to calculate correct week startdate with given date
import java.util.Date;
public class MyDate
public static void main(String args[]){
Date d1 = new Date();
System.out.println("The system date is "+d1.toString());
//enter some date and it should get starting date and ending date
//say for sample I enter 01/23/2006 and it should get
//start date as 12.00 AM 01/23/2006 and end date as 11.99 01/29/2006
//and it should automatically do whatever that gets for current
//date
Hi,
I have some date has current date and it should calculate starting date of the week and the
the next date that is 7 days old with one second less as described below
//enter some date and it should get starting date and ending date
//say for sample I enter 01/23/2006 and it should get
//start date as 12.00 AM 01/23/2006 and end date as 11.99 01/29/2006
//and it should automatically do whatever that gets for current
//date
Any help in this regard is appreciated.
Thanks
ChatfFor starters, you'll want to use the java.util.Calendar class.
-
How to Calculate number of months between two dates
Hi All,
In one of the fomr developments, I have to calculate the
Number of Days
Number of Months ( Considering Leap Year) provided by the dates, end user enters in the form,
After going thorugh some forum discussion, I have come to know about so many things which were not clear till now.
I have gone through various forums too, some one suggets to make use of FORM CALC and some other JAVA SCRIPT. But the logic i want to build in java script.
The most interesting point is the DATE object is not getting created when i write the below code
var startDate = new DATE(oYear, oMonth, oDay);
I am still not clear, that really the date object gets created in Adobe form If so the why the alert box is getting populated when i write below lines
var oTemp = startDate.getFullYear();
xfa.host.messagebox(oTemp);
So, there are so many unclear things,
If any one can help me by suggesting the approach and how to build the logic in the JavaScript I would be really thankful
Regards
PavanChandHi,
ChakravarthyDBA wrote:
Hi
I want number of Sundays between two dates
example
number of Sundays count between '01-04-2013' and '30-04-2013' in one select query I have to include this as sub query in my select statement.Here's one way:
SELECT early_date
, late_date
, ( TRUNC (late_date + 1, 'IW')
- TRUNC (early_date, 'IW')
) / 7 AS sundays
FROM table_x
;This does not depend on your NLS settings.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Point out where the statment above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
How to Calculate Total Worked Hours in a date range
<p><span>WorkedHours column type is varchar(8) (for HH:MM:SS), <br />how to sum working hours of an employee for every month.</span> <br /></p><p><span>ex. of data : WorkedHours<br /><br />attencode attendate WorkedHours<br />1573 20-01-2007 07:34:22<br />1573 21-01-2007 12:31:10<br /><br />how can i sum the WorkedHours and print it in Hours format.<br />(like 20.17 for this 2 values)<br /><br />Can u able to follow me.<br />If not pls. feel free to get more information in this regard.</span></p>
Create a formula like this :
((hour({tmpDate.attendate }) * 60 * 60) +
(minute({tmpDate.attendate }) * 60) +
Second({tmpDate.attendate }))/3600
and then take the Sum of it. You can get the result.
logic behind this is all the hours and minutes are converted into seconds and then added and divided by 3600 to get the actual hours.
thanks
kanak -
I have a situation, where i need to write expression Period to date(PTD). i want to know how to get the period date. i want you to help in writing Period date or else is there any function to get period date for a given date(the date is given
from the parameter dynamically) in MDX for SSRS report
ramHi ram,
Per my understanding that you want to get the period date based on the month selected and the given date, right?
Could you please provide details information below to help us better understanding your requirements, thus we will be more effective to provide an solution:
What is the format of the period date you want to get, is this date in the DB and you want to filter it based on the month and the given Date?
Did the month and given date are two parameters in the report? if possible, could you please provide some sample data in the DB and also the snapshot of the report structure
I assume you want to get the period date(mm/dd/yyy) between the select month(e.g:Feb) and the given date (10/1/2014) and you should get the date between(02/01/2014-10/1/2014).
If so,and you also have two parameter "Month","EndDate"(EndDate is the given date), please reference to details information below:
You can create an new parameter "BeginDate" (Date/Time) which is the begin date of the period, you can use the expression to get the value based on the value of the month and the year value from the given date,finally hide this parameter:
Specify the available value:
Label:=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value)
Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
Specify the default Value:
Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
Add filter to the dataset as below:
Preview you will get all the date in the given Period:
If you still have any problem, please feel free to ask.
Regards
Vicky Liu -
How to get LASTDAY for each and every month between given dates..
Hi Friend,
I have a doubt,How to get LASTDAY for each and every month between given dates..
for ex:
My Input will be look like this
from date = 12-01-2011
To date = 14-04-2011
And i need an output like
31-01-2011
28-02-2011
31-03-2011
is there any way to achieve through sql query in oracle
Advance thanks for all helping friendsHere's a 8i solution :
select add_months(
trunc(
to_date('12-01-2011','DD-MM-YYYY')
,'MM'
, rownum ) - 1 as results
from all_objects
where rownum <= ( months_between( trunc(to_date('14-04-2011','DD-MM-YYYY'), 'MM'),
trunc(to_date('12-01-2011','DD-MM-YYYY'), 'MM') ) );
The above two query is worked in oracle 11GActually the first query I posted is not correct.
It should work better with
months_between(
trunc(to_date(:dt_end,'DD-MM-YYYY'),'MM'),
trunc(to_date(:dt_start,'DD-MM-YYYY'),'MM')
)Edited by: odie_63 on 12 janv. 2011 13:53
Edited by: odie_63 on 12 janv. 2011 14:11 -
How can i add one month to a date variable ?
Unlike the week which always 7 days, month may change from 28 to
31, so how can i add one month to a date variable ? Thanks in
advance.Adding 365 won't always work because of leap years.
You could use the following SQL statement:
SELECT
TO_DATE(
TO_CHAR(TO_DATE(SYSDATE), 'DD-MON-') ||
(TO_CHAR(TO_DATE(SYSDATE), 'YYYY') + 1)) NEXT_YEAR
FROM
dual
NEXT_YEAR
08-JAN-03Or you could create your own function. You would use this
exactly like add_months:
CREATE OR REPLACE FUNCTION add_years
(v_date DATE, num_years NUMBER)
RETURN DATE AS
v_year DATE;
BEGIN
v_year := TO_DATE(
TO_CHAR(TO_DATE(SYSDATE), 'DD-MON-') ||
(TO_CHAR(TO_DATE(SYSDATE), 'YYYY')
+ num_years));
RETURN v_year;
END;
SELECT
add_years(SYSDATE, 1) new_year
FROM
dual
NEW_YEAR
08-JAN-03
SELECT
add_years(SYSDATE, -1) new_year
FROM
dual
NEW_YEAR
08-JAN-01 -
hi,
I want a function module which could calculate the previous month's start date and end date...
Say todays date is like 29.05.2007(start date) it should return
01.04.2007 and 30.04.2007...
IS there any FM for this ... or how to go about this scenario ???
thanks in advance
sammSee the below Logic :
DATA :g_date(2) TYPE n, " Date
g_month(2) TYPE n, " Month
g_year(4) TYPE n , " Year
g_bill_low(10) TYPE n, " From date
g_bill_high(10) TYPE n, " To date
g_month1(2) TYPE n, " Month
g_year1(4) TYPE n, " Year
g_date1(2) TYPE n, " Date
g_year2(4) TYPE n, " Year
g_datum LIKE sy-datum. " System date
RANGES : r_bdate FOR vbrk-fkdat. " Billing date
g_datum = p_date + 10.
g_month = g_datum+4(2).
g_year = g_datum+0(4).
IF g_month = 1.
g_year = g_year - 1.
g_month = 12.
g_date = 1.
ELSE.
g_month = g_month - 1.
g_date = 1.
ENDIF.
Passing the date to billing date-low
CONCATENATE g_year g_month g_date INTO g_bill_low.
r_bdate-low = g_bill_low.
r_bdate-sign = 'I'.
r_bdate-option = 'BT'.
g_month1 = g_datum+4(2).
g_year1 = g_datum+0(4).
IF g_month1 = 1.
g_year1 = g_year1 - 1.
g_month1 = 12.
ELSE.
g_month1 = g_month1 - 1.
ENDIF.
CASE g_month1.
WHEN 1.g_date1 = '31'.
WHEN 3.g_date1 = '31'.
WHEN 4.g_date1 = '30'.
WHEN 5.g_date1 = '31'.
WHEN 6.g_date1 = '30'.
WHEN 7.g_date1 = '31'.
WHEN 8.g_date1 = '31'.
WHEN 9.g_date1 = '30'.
WHEN 10.g_date1 = '31'.
WHEN 11.g_date1 = '30'.
WHEN 12.g_date1 = '31'.
ENDCASE.
g_year2 = g_year1.
IF g_month1 = 2.
g_year2 = g_year2 MOD 4 .
IF g_year2 = 0.
g_date1 = 29.
ELSE.
g_date1 = 28.
ENDIF.
ENDIF.
Passing the date to billing date-high
CONCATENATE g_year1 g_month1 g_date1 INTO g_bill_high.
r_bdate-high = g_bill_high.
APPEND r_bdate.
Reward Points if it is helpful
Thanks
Seshu -
Any FM to get count of each week day for the given date range
Hi guys,
Any FM to get count of each week day for the given date range?
eg: If i give 14/07/2008 to 14/08/2008
I need to find how many Mondays, tuesdays...sundays in this given date range.
If not single FM is available, any logic that gives above result is also appreciated.
Thanks,
Vinod.hi Vinod,
this is not a full solution, I just give you a basic idea:
DATA : lv_start TYPE sy-datum VALUE '20080714',
lv_end TYPE sy-datum VALUE '20080814'.
WHILE lv_start LE lv_end.
CALL FUNCTION 'FTR_DAY_GET_TEXT'
EXPORTING
pi_date = lv_start.
* IMPORTING
* PE_DAY_TEXT1 =
* PE_DAY_TEXT2 =
* PE_DAY =
* you have to summarize the output here somehow...
lv_start = lv_start + 1.
ENDWHILE.
hope this helps
ec -
Assign Month within a date range (by most days in a given month)
I have a begin and end date, sample data as such
select to_date('01-13-12','mm-dd-yy') from_dt,
to_date('02-23-12','mm-dd-yy') to_dt
from dual
union all
select to_date('03-15-2012','mm-dd-yy') from_dt,
to_date('04-16-2012','mm-dd-yy') to_dt
from dual
union all
select to_date('05-13-2012','mm-dd-yy') from_dt,
to_date('07-23-2012','mm-dd-yy') to_dt
from dual
How do I assign a month by the most days in a month within that date range? Sometimes the date range might have the exact same amount of days in a month (like 3/15/2012 has 16 days and 4/16/2012 has 16 days). In this case, I want the earlier month (march).
So from the sample data:
01/13/2012, 02/23/2012, February
03/15/2012, 04/16/2012, March
05/13/2012, 07/23/2012, June
Thanks
Edited by: user4422426 on Mar 1, 2012 5:15 PMHi,
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 code to create the same data. Please test your code before you post it: you got the order of arguments to TO_DATE reversed. -
Finding the number of weeks or months in a Date range
I have a couple of text boxes that a user inputs a start date and an end date. What I want to know is there a way to tell the number of months or the the number of days in this date range?
For example:
Start Date = 02/12/2004
End Date = 03/12/2004
The number of weeks = 4 //May not be accurate, just showing an example.
The number of months = 2For month, I would define it as the dates that fall in the actual calendar month. If my start date input from the user is 1/21/04, then I want to define a time period of 1/21/04 through 1/31/04 to be included in the first month. I know that it is not an actual month, but I am trying to make graphs based on monthly performance.
For weeks, I want the days to run Sunday through Saturday. If the first date starts on a Wednesday, then I want my first week to include days only Wednesday through Saturday. -
How to calculate the hour difference between two dates?
hi all,
how to calculate the hour difference between two dates?
eg i trying this...
((TO_DATE(TO_CHAR(GRNi.reference_date_4,'hh24:mi'),'hh24:mi') -
TO_DATE(TO_CHAR(NVL(GRNi.reference_date_3,SYSDATE),'hh24:mi'),'hh24:mi'))*24)*60 Act_Hr
Reg.
AAKHi
To break the diff between 2 dates into days, hours, minutes, sec -- you can use the following:
select to_char( created, 'dd-mon-yyyy hh24:mi:ss' ),
trunc( sysdate-created ) "Dy",
trunc( mod( (sysdate-created)*24, 24 ) ) "Hr",
trunc( mod( (sysdate-created)*24*60, 60 ) ) "Mi",
trunc( mod( (sysdate-created)*24*60*60, 60 ) ) "Sec",
to_char( sysdate, 'dd-mon-yyyy hh24:mi:ss' ),
sysdate-created "Tdy",
(sysdate-created)*24 "Thr",
(sysdate-created)*24*60 "Tmi",
(sysdate-created)*24*60*60 "Tsec"
from all_users
where rownum < 50
HTH
RangaReddy -
Working hours of an employee between a given date range
Hi Everyone,
how to calculate working hours of an employee between a given date range
Please anyone qive me some idea..
Thanks in advanceHi Lathessh,
Thanks for the reply here is the sample data. Actually we have two datetime field and i want to calculate the Ageing of an employee , by excluding of sunday and holiday between startdate and endDate.
Ageing should be in hours. Thanks
StartDateTime
EndDateTime
HolidayList
2/24/2014 11:55
3/1/2014 16:45
1/1/13 0:00
2/24/2014 12:08
2/28/2014 12:55
1/14/13 0:00
2/24/2014 16:16
2/28/2014 15:20
1/25/13 0:00
2/14/2014 12:56
3/4/2014 16:20
3/27/13 0:00
2/14/2014 12:56
3/4/2014 16:20
3/29/13 0:00
2/14/2014 12:56
3/4/2014 16:20
4/24/13 0:00
2/14/2014 12:56
3/4/2014 16:20
5/1/13 0:00
2/26/2014 13:53
3/4/2014 16:20
8/9/13 0:00
2/27/2014 12:13
3/5/2014 13:05
8/15/13 0:00
3/3/2014 14:42
3/5/2014 17:05
8/20/13 0:00
3/3/2014 14:42
3/5/2014 17:05
8/28/13 0:00
3/3/2014 14:42
3/5/2014 17:05
9/18/13 0:00
3/6/2014 12:28
3/6/2014 17:55
10/2/13 0:00
3/6/2014 12:59
3/7/2014 13:55
10/16/13 0:00
3/6/2014 14:37
3/7/2014 11:15
11/5/13 0:00
3/6/2014 14:57
3/7/2014 12:10
11/15/13 0:00
3/4/2014 17:21
3/10/2014 15:55
12/4/13 0:00
3/4/2014 17:21
3/10/2014 15:55
12/25/13 0:00
3/6/2014 12:08
3/10/2014 14:10
12/31/13 0:00
3/6/2014 13:31
3/10/2014 13:05
1/1/14 0:00
3/6/2014 13:14
3/11/2014 13:20
1/14/14 0:00
3/6/2014 13:14
3/11/2014 13:20
3/17/14 0:00
3/11/2014 14:29
3/13/2014 11:20
4/8/14 0:00
3/11/2014 14:29
3/13/2014 11:20
4/14/14 0:00
3/12/2014 12:56
3/13/2014 11:45
4/18/14 0:00
3/12/2014 12:56
3/13/2014 11:45
5/1/14 0:00
3/12/2014 14:02
3/12/2014 18:10
7/29/14 0:00
3/12/2014 14:22
3/12/2014 18:05
8/15/14 0:00
2/24/2014 16:49
3/14/2014 12:10
8/18/14 0:00
2/24/2014 16:49
3/14/2014 12:10
8/29/14 0:00
2/24/2014 16:49
3/14/2014 12:10
10/2/14 0:00
2/24/2014 16:49
3/14/2014 12:10
10/3/14 0:00
3/12/2014 11:31
3/14/2014 15:55
10/6/14 0:00
3/12/2014 13:31
3/15/2014 12:20
10/23/14 0:00
3/12/2014 15:31
3/15/2014 11:10
10/24/14 0:00
3/12/2014 15:49
3/14/2014 13:55
12/25/14 0:00
3/12/2014 16:19
3/14/2014 15:05
12/31/14 0:00 -
List Months between a date range
Hi, I'm trying to list the months between a given date range in an ABAP report to generate a MIS report(ALV).. Say I have 2 date ranges, 01.01.2006 to 01.04.2006.. I want to list
Jan 2006
Feb 2006
Mar 2006
Apr 2006.. Any FM in SAP to get this OP..hi vivek,
use this function module to get months beween two dates
1. MONTHS_BETWEEN_TWO_DATES or
2. MONTHS_BETWEEN_TWO_DATES_NEW
please reward the point if you are satisfied with answer
thanks,
john. -
Get table partition name dynamically for given date range
Dear All,
Could you please tell me how to get the partition name dynamicaly for given date range ?
Thank you.SQL> select table_name,
partition_name,
to_date (
trim (
'''' from regexp_substr (
extractvalue (
dbms_xmlgen.
getxmltype (
'select high_value from all_tab_partitions where table_name='''
|| table_name
|| ''' and table_owner = '''
|| table_owner
|| ''' and partition_name = '''
|| partition_name
|| ''''),
'//text()'),
'syyyy-mm-dd hh24:mi:ss')
high_value_in_date_format
from all_tab_partitions
where table_name = 'SALES' and table_owner = 'SH'
TABLE_NAME PARTITION_NAME HIGH_VALUE_IN_DATE_FORMAT
SALES SALES_1995 01-JAN-96
SALES SALES_1996 01-JAN-97
SALES SALES_H1_1997 01-JUL-97
SALES SALES_H2_1997 01-JAN-98
SALES SALES_Q1_1998 01-APR-98
SALES SALES_Q2_1998 01-JUL-98
SALES SALES_Q3_1998 01-OKT-98
SALES SALES_Q4_1998 01-JAN-99
SALES SALES_Q1_1999 01-APR-99
SALES SALES_Q2_1999 01-JUL-99
SALES SALES_Q3_1999 01-OKT-99
SALES SALES_Q4_1999 01-JAN-00
SALES SALES_Q1_2000 01-APR-00
SALES SALES_Q2_2000 01-JUL-00
SALES SALES_Q3_2000 01-OKT-00
SALES SALES_Q4_2000 01-JAN-01
SALES SALES_Q1_2001 01-APR-01
SALES SALES_Q2_2001 01-JUL-01
SALES SALES_Q3_2001 01-OKT-01
SALES SALES_Q4_2001 01-JAN-02
SALES SALES_Q1_2002 01-APR-02
SALES SALES_Q2_2002 01-JUL-02
SALES SALES_Q3_2002 01-OKT-02
SALES SALES_Q4_2002 01-JAN-03
SALES SALES_Q1_2003 01-APR-03
SALES SALES_Q2_2003 01-JUL-03
SALES SALES_Q3_2003 01-OKT-03
SALES SALES_Q4_2003 01-JAN-04
28 rows selected.
Maybe you are looking for
-
Hi Seniors, Please help me with this issue........i have to develope a New report Vendor balance Reconcillation ......Using the Standard report S_ALR_87012082 vendor balances in local currency.....it should be same like this Standard report
-
Help plz ipod id not recnized by computer
it norenizing my ipod i need help i used disk mode it dont work nither dose the 5rs my ipod was synic wit another compur and i need help plz
-
OCA and OCP Post-nominal letters
Hi All, I recently passed OCA and OCP for Java 7. I was wondering if there is an official industry accepted standard to place these qualifications after your name. I saw Bert Bates, co-author of the Java 7 study guide, placed: Bert Bates OCA OCP. Is
-
Error when compile package.
create or replace package body test_data is V_STARTDATE DATE; PROCEDURE CATEGORY_EXPORT aS cursor C1 is select expdate from local_Category_Data loc; end category_us_export; end test_data; gives error "encountered the symbol end when expecting the fol
-
I was downloading the movie, Mighty Joe Young not the music to Mighty Joe Young. I was trying to download it to my computer. I don't want to pay for anything I didn't order.