Calculation based on date but year&month on seperate fileds.
Hello,
Simple question:
I have a table in 9i with the fields SOURCE, YEAR, MONTH
Since I dont have a date field, how do I count e.g the records <07/2008 ?
SAMPLE DATA:
APPLES;2008;06
APPLES;2008;07
APPLES;2008;08
Thank you in advance for your help.
Without conversion to date:
WITH sample_data AS (SELECT 'APPLES' Source, '2008' AS Year, '06' AS Month
FROM DUAL
UNION ALL
SELECT 'APPLES', '2008', '07'
FROM DUAL
UNION ALL
SELECT 'APPLES', '2008', '08'
FROM DUAL)
SELECT *
FROM sample_data
WHERE YEAR < '2008' OR (YEAR = '2008' AND MONTH < '07');The "WITH sample_data AS (...)" block serves to mimic a sample table, so you can SELECT COUNT(*) FROM SOURCES
WHERE YEAR < '2008' OR (YEAR = '2008' AND MONTH < '07');Urs
Edited by: metzguar on 30.06.2011 13:15
Similar Messages
-
Date separate year, month and day
Hello everyone and thanks in advance, I'm new to this and the truth is not doing this.
Well, I have a PDF with several pages which I designed and has been asking me in a complete date in the format dd / mm / yy and subsequent pages he asks me the same date of birth but in 3 separate fields, day , month and year. I want you when you enter the date the first copy and separate day month and year in others. I tried this but I get
var array_datesol = datesol.split("/")
var year = parseInt(array_datesol[2]);
var month = parseInt(array_datesoll[1]);
var day = parseInt(array_datesol[0]);
this.getField('yearsol').value = year;
this.getField('monthsol').value = month;
this.getField('daysol').value = day;
where is the initial field datesol date and year, month and day where they have to be separately
thanks in advanceAre you getting any errors in the JavaScript debugging console?
You are using the syntax for the 'Custom JavaScript calculation' and this syntax can not be used in the 'simplified field notation. Also you can not use any JavaScript properties, objects, functions, control statments.
When run in the console, I find you have a misspelling of the variable name 'datesol'. I also do not see where you are initializing the value for 'datesol'.
var datesol = event.valueAsString; // get value of this field
var array_datesol = datesol.split("/") ; // make into an array
this.getField('yearsol').value =array_datesol[2]; // get element year
this.getField('monthsol').value = array_datesol[1]; // get month element - fixed variable name
this.getField('daysol').value = array_datesol[0]; // get date element
I would use one of the following so the other fields are only updated when a date has been entered and the leading zeros are displayed:
this.getField('yearsol').value = '';
this.getField('monthsol').value = '';
this.getField('daysol').value = '';
if(event.value != '') {
// get parts of date and print with leading zeros
var datesol = event.value; // get value of this field
var array_datesol = datesol.split('/') ; // make into an array
this.getField('yearsol').value = util.printf('%,304.0f', array_datesol[2]); // get element year
this.getField('monthsol').value = util.printf('%,302.0f', array_datesol[1]); // get month element - fixed variable name
this.getField('daysol').value = util.printf('%,302.0f', array_datesol[0]); // get date element
// or
this.getField('yearsol').value = '';
this.getField('monthsol').value = '';
this.getField('daysol').value = '';
if (event.value != '') {
// get date parts and print with leading zeros
var oDatesol = util.scand('dd/mm/yyyy', event.value); // get date object
this.getField('yearsol').value = util.printf('%,302.0f',oDatesol.getFullYear()); // get element year
this.getField('monthsol').value = util.printf('%,302.0f', oDatesol.getMonth() + 1); // get month element - fixed variable name
this.getField('daysol').value = util.printf('%,302.0f', oDatesol.getDate()); // get date element
// or
this.getField('yearsol').value = '';
this.getField('monthsol').value = '';
this.getField('daysol').value = '';
if(event.vaue != '') {
// get parts of date and format
var oDatesol = util.scand('dd/mm/yyyy', event.value); // get date object
this.getField('yearsol').value = util.printd('yyyy', oDatesol); // get element year
this.getField('monthsol').value = util.printd('mm', oDatesol); // get month element - fixed variable name
this.getField('daysol').value = util.printd('dd', oDatesol); // get date element
If you are going to fill other field, you will need to use the '.valueAsStriing' property or '.toString()' method to retain the leading zeros. -
How to get the difference of two dates in years,months and days
Hi friends,
how to get the difference of two dates in years,months and days
for ex 2 years 3 months 13 days
select (sysdate-date_Start) from per_periods_of_service
thanksSomething like this...
SQL> ed
Wrote file afiedt.buf
1 with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
2 select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
3 select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
4 )
5 -- end of test data
6 select c_start_date, c_end_date
7 ,trunc(months_between(c_end_date, c_start_date) / 12) as yrs
8 ,trunc(mod(months_between(c_end_date, c_start_date), 12)) as mnths
9 ,trunc(c_end_date - add_months(c_start_date, trunc(months_between(c_end_date, c_start_date)))) as dys
10* from t
SQL> /
C_START_D C_END_DAT YRS MNTHS DYS
17-NOV-06 21-JAN-08 1 2 4
21-NOV-06 17-FEB-08 1 2 27
21-JUN-06 17-JUL-08 2 0 26
SQL>But, don't forget that different months have different numbers of days, and leap years can effect it too. -
Calculation based on date key figures in BEx
Hi Friends,
Hi Friends,
I need to creat report for sales order data, which involved the calculation based on dates.
In my cune iam having the data at the granual level with the dates as key figures. the calculation that i need to do is VTW = Actual PGI date - Customer want date.
1) whn i run the report at the granual level my VTW is working correctly. No issues.
2) when i run the report at higher levels the date fields are updated with X, as the system is unable to aggrigate the dates. The dates are at the material level in a sales order. I need to show the VTW at the sales order level (each one of the two dates are same for all the materials). So, when i run the report with out mataril at the sales order level...i wanto sea the bothe date fields in a single line and also the VTW calculated as the different between throse two dates.
3) Once we get the VTW correctly at the sales orde level. if i drill down the report for material, i want to sea both the dates in every record againest the matarial, but the VTW only aginest the first record...that is againest the sales order. I dont waht the VTW value repeated/duplicated for all the records againest the sales order,as VTW makes sence only at the Sales Order level.
Please suggest me hwo i can achive the resulsts by meeting both Point 2 and 3.
Thanks for ur help...in advance.
Thanks,
RenuHi..
I have the data from the extractore and in the cube as below.
SALES ORDER ITEM MATERIAL DATE1 DATE2
101 Item1 Mat1 01/01/2010 15/01/2010
101 Item2 Mat2 01/01/2010 15/01/2010
101 Item3 Mat3 01/01/2010 15/01/2010
I need the reports as below...
Report1:
SALES ORDER DATE1 DATE2 VTW (DATE2 - DATE1)
101 01/01/2010 15/01/2010 14
currently iam getting this Report1 output as below...
SALES ORDER DATE1 DATE2 VTW (DATE2 - DATE1)
101 X X 42
Report2: Out put required as below
SALES ORDER ITEM MATERIAL DATE1 DATE2 VTW (DATE2 - DATE1)
101 Item1 Mat1 01/01/2010 15/01/2010 14
101 Item2 Mat2 01/01/2010 15/01/2010
101 I tem3 Mat3 01/01/2010 15/01/2010
currently iam getting this Report2 output as below...
SALES ORDER ITEM MATERIAL DATE1 DATE2 VTW (DATE2 - DATE1)
101 Item1 Mat1 01/01/2010 15/01/2010 14
101 Item2 Mat2 01/01/2010 15/01/2010 14
101 I tem3 Mat3 01/01/2010 15/01/2010 14
As VTW is need to be measued at the sales order level and we always have the DATE1 & DATE2 as same for all the itesm, it should be shon as only 14 in the first record. It mean once iget the required output from Report one in a single line with VTW as 14, it should not repeat with every line , when i dril down the report for Items or materials.
Even if i can generate oly report2 as required in a single sheet ...that will be enough.
Plas kindly provide some solution as how we can achieve this,
Thanks,
Renu -
Find date if year, month, week and day is given
Hi,
How to find the date, if year, month, week and day is given?
For example:
Given, year - 2010, month - 03, Day - Wednesday, Week - 3,
Then how can we get the date as 17-Mar-2010.
Thanks,
Chriswith dt_tbl as (
select 2010 year,
3 month,
3 week,
'Wednesday' day
from dual
select trunc(to_date(year || '-' || month || '-01','yyyy-mm-dd'),'iw') + (week - 1) * 7 +
case day
when 'Monday' then 0
when 'Tuesday' then 1
when 'Wednesday' then 2
when 'Thursady' then 3
when 'Friday' then 4
when 'Saturday' then 5
when 'Sunday' then 6
end dt
from dt_tbl
DT
17-MAR-10
SQL> SY. -
Hello,
We need some help with an SSAS MDX query based on date logic. One of the problems is that I don't have access to the Cube but have been given a query example with the logic needed for the calculation. Here's the scenario;
The ETL process will run on the first Tuesday after the 15<sup>th</sup> of a given month. The Analysis Cube data queried should include the current year up to the end of the previous month. For example, on May 19<sup>th</sup>
(the first Tuesday on or after the 15th) the query should include data from January 1<sup>st</sup> through April 30<sup>th</sup>.
The 15<sup>th</sup> of the month is not part of the query, it is a factor in when the query is run. The query will always be in terms of complete months.
SELECT
NON EMPTY { [Measures].[Revenue Amount],
[Measures].[Utilization],
[Measures].[AVG Revenue Rate],
[Measures].[Actual Hours] }
ON
COLUMNS,
NON EMPTY { ([dimConsultant].[User Id TT].[User Id TT].ALLMEMBERS * [dimConsultant].[Full Name].[Full Name].ALLMEMBERS * [dimConsultant].[Employee
Type].[Employee Type].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION,
MEMBER_UNIQUE_NAME
ON
ROWS
FROM
( SELECT
( { [dimDate].[Week Date].[1/4/2015], [dimDate].[Week Date].[1/11/2015], [dimDate].[Week Date].[1/18/2015], [dimDate].[Week Date].[1/25/2015], [dimDate].[Week Date].[2/1/2015] } )
ON
COLUMNS
FROM
( SELECT
( { [dimIsBillable].[Is Billable].&[True] } )
ON
COLUMNS
FROM
[SSASRBA]
WHERE
( [dimIsBillable].[Is Billable].&[True], [dimDate].[Week Date].CurrentMember ) CELL PROPERTIES VALUE,
BACK_COLOR,
FORE_COLOR,
FORMATTED_VALUE,
FORMAT_STRING,
FONT_NAME,
FONT_SIZE,
FONT_FLAGSHi Hans,
Thank you for your question.
I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.
Thank you for your understanding and support.
Regards,
Simon Hou
TechNet Community Support -
Hi there:
I've created a SSRS report based on OLAP cube. In this report, there is a date parameter which is used to filter out data.
Now , I want this report to be run and always retrieve data from previous day. I need to supply the date parameter with something
like SQL syntax: DATEADD(dd,-1,GETDATE()) . The question is how can I do that in the MDX world?
thanks
Hui
--Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --Hi Hui,
According to your description, you need to retrieve data from previous day, so you are looking for an expression in MDX which can achieve the requirement like SQL syntax: DATEADD(dd,-1,GETDATE()), right?
As per my understanding, it easy to achieve this requirement in report level ranther than in MDX query level. You can create another hidden parameter "Date2" using the expression below.
=DateAdd("d",-1,Parameters!Date.Value)
Then use Date2 parameter to filter in the query.
If don't want to create another parameter, you can use it like below.
Year =DatePart("yyyy",DateAdd("d",-1,Parameters!Date.Value))
Quarter =DatePart("qq",DateAdd("d",-1,Parameters!Date.Value))
Month =DatePart("mm",DateAdd("d",-1,Parameters!Date.Value))
Week =DatePart("ww",DateAdd("d",-1,Parameters!Date.Value))
Besides, DateAdd function is supported in MDX, please refer to the link below.
http://msdn.microsoft.com/en-us/library/hh510163.aspx
If I have anything miunderstand, please point it out.
Regards,
Charlie Liao
If you have any feedback on our support, please click
here.
Charlie Liao
TechNet Community Support -
Retirement Date Calculation based on Date Of Birth
Hi All,
We have 11.1.2.2 PSPB Application where we have requirement to calculate "Retirement date" (in the format dd/mm/yyyy) based on employee's "Date Of Birth", for which i tried with @DateRoll function, but no luck. For time being we tried "Retirement Year" which was successful.
"Retirement Year"=@INT ("Date Of Birth"/10000)+60;
For Example: If Employee's Date of Birth is 7/11/1946 thru above script i got 2006 as his "Retirement Year", now i need "Retirement Date" as 6/11/2006 which im not getting. I tried in all ways like:
1) "Retirement Date"=@DateRoll ("Date Of Birth",DP_YEAR,1); got output as 31/03/5127 for "Date Of Birth" 01/01/1975
2)"Retirement Date"= @FORMATDATE ("yyyyddmm",@DateRoll ("Date Of Birth",DP_YEAR,1)); no luck.
3)"Retirement Date"=@DATEDIFF (@Today(),"Date Of Birth",DP_YEAR)); no luck.
Also all the Date functions like @DateRoll,@FromatDate,@DateDiff etc returns number representing the date between January 1, 1970 and Dec 31, 2037, is that true? If yes, what functions needs to be used for "Date of Birth" above the range.
Please suggest ASAP.
Thanks in advance.
Regards,
SahiIf anyone's interested, I found a solution
if (DropDownGuarantee.rawValue eq "1" and DteStart.rawValue ne null) then
Num2Date(Date2Num(DteStart.formattedValue, "M/D/YYYY") + 30, "M/D/YYYY")else
if (DropDownGuarantee.rawValue eq "2" and DteStart.rawValue ne null) then
Num2Date(Date2Num(DteStart.formattedValue, "M/D/YYYY") + 30, "M/D/YYYY")else
if (DropDownGuarantee.rawValue eq "3" and DteStart.rawValue ne null) then
Num2Date(Date2Num(DteStart.formattedValue, "M/D/YYYY") + 60, "M/D/YYYY")else
if (DropDownGuarantee.rawValue eq "4" and DteStart.rawValue ne null) then
Num2Date(Date2Num(DteStart.formattedValue, "M/D/YYYY") + 60, "M/D/YYYY")else
if (DropDownGuarantee.rawValue eq "5" and DteStart.rawValue ne null) then
Num2Date(Date2Num(DteStart.formattedValue, "M/D/YYYY") + 60, "M/D/YYYY")else
if (DropDownGuarantee.rawValue eq "6" and DteStart.rawValue ne null) then
Num2Date(Date2Num(DteStart.formattedValue, "M/D/YYYY") + 90, "M/D/YYYY")else
if (DropDownGuarantee.rawValue eq "7" and DteStart.rawValue ne null) then
Num2Date(Date2Num(DteStart.formattedValue, "M/D/YYYY") + 90, "M/D/YYYY")else
if (DropDownGuarantee.rawValue eq "8" and DteStart.rawValue ne null) then
Num2Date(Date2Num(DteStart.formattedValue, "M/D/YYYY") + 90, "M/D/YYYY")else
if (DropDownGuarantee.rawValue eq "0" and DteStart.rawValue ne null) then
Num2Date(Date2Num(DteStart.formattedValue, "M/D/YYYY"), "M/D/YYYY")else
if (DropDownGuarantee.rawValue eq "9" and DteStart.rawValue ne null) then
"enter expiration date"
Marlene -
How to Transfer TCA to other database based on date or year range.
Hi Experts,
I want to transfer TCA current year's information only to the other database in 11.5.10.2 version. Please help if someone can refer to any procedure/document for transferring TCA from our current productoin database to another test instance. I want to limit the TCA transfer to current year's information only. Would be good to have date range syntax for that filter.
Thanks
AsifAny help on this please.
Thanks
Asif -
Difference between two dates is required in years & months
Hi all,
<b>1.</b> I want difference of two dates in years & months. For e.g. date1 is 29.09.1998 & date2 is 02.05.2001. I want date2-date1 to be calculated & displayed as 2.7 (yrs)in BEx.
<b>2. </b> Also, while calculating overalll result it should calculate as :
E.g. 2.7+ 2.6 = 5.1 (yrs)
Right now I am getting difference in days. Is there any way to convert it in yrs & months.
Note:string 'yrs' is not required
Thanks in advance.
HimanshuHi,
Reply by Arun was immensely helpful.
To do calculation I used the following formula.
TRUNC ( 'DATE DIFFERENCE' / 365 ) + TRUNC ( FRAC ( 'DATE DIFFERENCE' / 365 ) * 12 ) / 100
where 'DATE DIFFERENCE' is difference of two dates in days (Employment start date - employment end date). By this I am getting number of days in years & months. -
Customer Exit Variable on Cal Year/Month Error
Hi Experts
My requirment is to develop a Restricted Keyfigure...
The restriction is based on 0Calmonth (Calendar Year/Month)
The sales from beginning of calendar year up to last "closed" month in a Calendar.
Ex: in June i want to see 01.01.2009 to 31.05.2009 data.
in October i want to see 01.01.2009 to 30.09.2009 data.
When user execute the report
in Jan 2010 i want to see 0 as there is no closed month in that particular year.
in Fed 2010 i want to see 01.01.2010 to 31.01.2010 data.
For that purpose i created a variable
Customer Exit on calendar Year/Month
Variable represents : Interval
Variable is : Mandatory
Variable is Ready for Input (Uncheck)
in CMOD...i had written The below Code
WHEN 'ZYCCM' . "Current Year Culm. to Last Closed Month
DATA :Month(2) type c,
Start_Month like rsd_c_timnm-calmonth,
End_Month like rsd_c_timnm-calmonth.
Month = sy-datum+4(2).
if Month = '01'.
Start_Month = '000000'.
End_Month = '000000'.
Else.
concatenate sy-datum(4)'01' into Start_Month.
End_Month = sy-datum(6) - 1.
Endif.
CLEAR L_S_RANGE.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
L_S_RANGE-LOW = Start_Month.
L_S_RANGE-HIGH = End_Month.
When i execute the report i am getting an error
"No Value Could be determined for Variable ZYCCM"
Please update what went wrong and how to Correct errorHi
Thanks for the update..
Modified code as below
WHEN 'ZYCCM' . "Current Year Culm. to Last Closed Month
DATA :Month(2) type c,
Start_Month like rsd_c_timnm-calmonth,
End_Month like rsd_c_timnm-calmonth.
Month = sy-datum+4(2).
if Month = '01'.
Start_Month = '000000'.
End_Month = '000000'.
Else.
concatenate sy-datum(4)'01' into Start_Month.
End_Month = sy-datum(6) - 1.
Endif.
CLEAR L_S_RANGE.
L_S_RANGE-LOW = Start_Month.
L_S_RANGE-HIGH = End_Month.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND l_s_range TO e_t_range.
But when i executed the report....the report is executed sucessfully but the restriction applied to only Jan 2009
When i saw the KF definition in RSRT
I EQ JAN 2009
I am expecting
BT JAN2009 APRIL2009
Please help
Tahnks -
Want the Average of sales for months up to date, with empty months included
How do I create an MDX that gives me the average of , f.ex., Sales
Note that some months may not have sales, but the month should still be counted.
The result I want to get out is a listing of Years with average of Sales for each year. Where current year only calculates up to current month.
Lets say that todays month is 2014-05 and we have the following figures for this year.
Month Sales
2014-01 10
2014-02 20
2014-03 Null
2014-04 15
2014-05 10
The calculation should be Sum(Sales) divided by 5 months: 55/5 = 11
If I use:
Avg( Descendants([Date].[Calendar].[Month].CurrentMemeber
, [Date].[Calendar].[Month])
, [Measures].[Internet Sales]
It will exclude 2014-03, which is wrong!
If I use CoalesceEmpty() to fill in the Nulls:
Avg( Descendants([Date].[Calendar].[Month].CurrentMemeber
, [Date].[Calendar].[Month])
, CoalesceEmpty([Measures].[Internet Sales],0)
It will fill in 0 for all months 2014 (up to 2014-12), which is also wrong!
It feels like a really simple calculation, but I can't make it work.
ThanksI finally had to fix it by checking the number of months to get it right.
This solved my problem and gave me the correct averages on year and month level.
Create Member CurrentCube.[Measures].[COMPLAINT COUNT AVG CALC] As Null
,Format_String = ";;;\N\/\A",VISIBLE = 1;
// For Year level - Show average of year = Sum/NumOfMonth. If this year then up to this month else divide by 12
SCOPE([COMP CREATION DATE].[YEAR].[YEAR], [Measures].[COMPLAINT COUNT AVG CALC]);
This = IIF([COMP CREATION DATE].[IS THIS YEAR].&[Y],
DIVIDE(SUM([COMPLAINT Count]), Format(now(), "MM")),
DIVIDE(SUM([COMPLAINT Count]), 12)
Format_String(This)="# ### ##0";
NON_EMPTY_BEHAVIOR(This) = { [Measures].[COMPLAINT Count] };
END SCOPE;
// For month level - Show average of month = Sum/NumOfDaysInMonth
SCOPE( [COMP CREATION DATE].[Year-Month-Date].[YEAR MONTHNO], [Measures].[COMPLAINT COUNT AVG CALC]);
This = IIF(not isempty([Measures].[COMPLAINT Count]),
Avg(
Descendants(
[COMP CREATION DATE].[Year-Month-Date].CurrentMember,
[COMP CREATION DATE].[Year-Month-Date].[DATE ID]
CoalesceEmpty([Measures].[COMPLAINT Count],0)
,Null
Format_String(This)="# ### ##0";
NON_EMPTY_BEHAVIOR(This) = { [Measures].[COMPLAINT Count] };
END SCOPE;
mStenport -
How to set current year,month as default value in combo box
hi, im newbie of xcelsius user
i realize that hv a issue that display combo box base on year & month
let said
<b><u>step 1</u></b>
I create excel data like this
<b><u>year___ </u> </b> | <u><b>month_ </b></u> | <u><b>Product</b></u> | <u><b>revenue</b></u>
02-04-09 | 02-04-09 | a | $4,154
03-04-09 | 03-04-09 | b | $6,813
04-05-09 | 04-05-09 | a | $9,875
05-06-09 | 05-06-09 | b | $6,813
06-04-10 | 06-04-10 | a | $6,813
07-04-10 | 07-04-10 | b | $9,875
08-06-10 | 08-06-10 | a | $9,875
22-06-10 | 22-06-10 | b | $6,813
<u><b>Step2</b></u>
Then i go format cell to format/custom date to year & month
Eg1: Year u2013> 02-04-09 convert to u2018YYYYu2019 (2009)
Eg2: Month u2013> 02-04-09 convert to u2018mmmmu2019 (April)
So output like this
<u><b>year</b></u> | <u><b>month</b></u> | <u><b>Product</b></u> | <u><b>revenue </b></u>
2009 | April | a | $4,154
2009 | April | b | $6,813
2009 | May | a | $9,875
2009 | June | b | $6,813
2010 | April | a | $6,813
2010 | April | b | $9,875
2010 | June | a | $9,875
2010 | June | b | $6,813
But the problem is when i insert to combo box,use u201Cfilter Row u201D, i excpectation will display only 2009,2010
But Actual display the Year in combo box is duplicated :'(
so any solution ? and then only how to set current year & month as default value :'(
thanks,
regards
s1
Edited by: Leong Pui Kee on Feb 25, 2011 5:25 AM
Edited by: Leong Pui Kee on Feb 25, 2011 5:36 AMhi,
your created data
step 1
I create excel data like this
year___ | month_ | Product | revenue
02-04-09 | 02-04-09 | a | $4,154
03-04-09 | 03-04-09 | b | $6,813
04-05-09 | 04-05-09 | a | $9,875
05-06-09 | 05-06-09 | b | $6,813
06-04-10 | 06-04-10 | a | $6,813
07-04-10 | 07-04-10 | b | $9,875
08-06-10 | 08-06-10 | a | $9,875
22-06-10 | 22-06-10 | b | $6,813
In this, year and month both are same data, make the diffent data like year 2009, 2010 And month Jan, Feb, March, ...Etc
and also one more check you formulas on month and year, select correct source data, destination data for compoonent..
OR
from above, to create a date column and convert date-->year, date--> month and Explore it.
All the best,
Praveen -
How can I find the difference between two dates in months?
I assume I can't do this:
Date firstDate = 4/1/2000;
Date secondDate = 6/1/2002;
int monDiff = secondDate - firstDate;
Also is it better to use java date or sql date?
thx.Here is a method that will compute the difference in years, months, and days. It's a bit more tricky that the previous post suggested when you take into account the day of the month. I'm not sure but I think that when you add a month to a date as in the suggested code you may have odd things happen when you go from Jan 31 to Feb to March since Feb may only have 28 days in it.
* Compute the difference between two dates in years, months, and days.
* The result is returned in a concatenated integer value of the form
* ymmdd. So the difference between Apr 20, 2003 and Apr 15, 2025 would
* be 211126 (21 years, 11 months, and 26 days) since 21 years and
* 11 months gets you to May 20 2025, there are 31 days in May of 2025,
* and it takes 25 days to go from May 20 2025 to April 15 2025! To split
* the values off,
* #years = return value / 10000,
* #months = return value % 10000 / 100
* #days = return value % 100.
* This method will return a negative value if the 'from' value is after the
* 'to' value (i.e. getDiff( from, to) = -getDiff( to, from )).
* @param pFrom The time to compute the difference from.
* @param pTo Date The time to compute the difference to.
* @return int The differenct in the two dates in the form ymmdd.
public static int getDiff( java.util.Date pFrom, java.util.Date pTo )
int lMultiplier = 1;
if ( pFrom.after( pTo ) );
lMultiplier = -1;
java.util.Date pTemp = pTo;
pTo = pFrom;
pFrom = pTemp;
Calendar lFrom = new GregorianCalendar();
lFrom.setTime( pFrom );
Calendar lTo = new GregorianCalendar();
lTo.setTime( pTo );
int lFromYear = lFrom.get( Calendar.YEAR );
int lFromMonth = lFrom.get( Calendar.MONTH );
int lFromDay = lFrom.get( Calendar.DAY_OF_MONTH );
int lToYear = lTo.get( Calendar.YEAR );
int lToMonth = lTo.get( Calendar.MONTH );
int lToDay = lTo.get( Calendar.DAY_OF_MONTH );
int lYearDiff = lToYear - lFromYear;
int lMonthDiff = lToMonth - lFromMonth;
int lDayDiff = lToDay - lFromDay;
if ( lDayDiff < 0 )
lMonthDiff--;
Calendar lTemp = new GregorianCalendar();
lTemp.setTime( pTo );
lTemp.add( lTemp.MONTH, -1 );
lDayDiff = lTemp.getActualMaximum( lTemp.DAY_OF_MONTH ) + lDayDiff;
if ( lMonthDiff < 0 )
lYearDiff--;
lMonthDiff = 12 + lMonthDiff;
return lMultiplier * ( lYearDiff * 10000 + lMonthDiff * 100 + lDayDiff );
} -
FM to get the number of days in Year,month and days by giving number of day
Hi ALL,
This is quit differnt.
I need to give input the 'start date' and the 'number of days' and get the total days from the start date in year,month and day format.
for example.
start date :01.01.2009
number of days as 32
then i should get
years:0
months :1
days :1
Pleas help me out.hi Anusha,
first u pass the date and the days to the following fm you will get the result date....
data:date type sy-datum,
r_date(10) type c.
date = sy-datum.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
DAYS = '32'
MONTHS = '0'
START_DATE = date
IMPORTING
RESULT_DATE = r_date
write:/ r_date.
then you need to pass the result date and the date to the following fm to get the required output...
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = r_date
date2 = date
IMPORTING
years = v_years
months = v_months
days = v_days
EXCEPTIONS
invalid_dates_specified = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
here u will get the difference in days, months and year...
i hope u wil get help from this...
regards
Ashu Singh
Maybe you are looking for
-
Can't open an Executable From Click Button
Hi, Everyone! I've broken a learning module into several small project files to match the client's standards. I've set up click buttons within each file to open each of the published movies for the module. Everything works as expected. Now I need to
-
HT3669 My HP Photosmart 4480 its not scaning on my MAC OS X Mavericks 10.9.2
My mac have OS X Mavericks 10.9.2 and my HP Photosmart C4480 its printing fine but im having trouble scaning, when i checked on apple site printer softwares i dont see mine listed only the HP photosmart C4400, y deleted/added few times and the scanne
-
Macbook pro late 2011. Have power on the battery but doesn't turn on at all.
Macbook pro late 2011. Have power on the battery but doesn't turn on at all. Not even a sound, my mac has stayed turned off in nearly a month and now its not working??? Any ideas to what the problem could be? Regards// Michael
-
Rebuild Authorizational data (User Buffer) Dynamically
We want to rebuild the authorizational data in a user's buffer by adding additional authorizations (auth obj with field values) during the logon procedure (user exit) (by executing a function module which will read a custom table) - however this has
-
Shot in 16:9 need to print to tape in 4:3
I shot in 16:9 (with Sony DSR500) and I need to print to tape in 4:3. I cannot find a way without squashing my images. (Re-capturing is not possible). Can I export or print a 16:9 timeline as 4:3? -C