‎2006 Jan 01 10:36 AM
i'm lokking for a function that give me the date year before' example:
01-05-2005
i want to get 01-01-2005------01-05-2005
and 01-05-2005------31-12-2004
‎2006 Jan 01 6:35 PM
Your example date is 01-05-2005. Can you tell us if it MM-DD-YYYY or DD-MM-YYYY?
From this input you want two ranges
First Range
From Date of the range = 01-01-2005 (Begining date of the year of the input)
To Date of the range = 01-05-005 (Input Date)
Second Range
From Date of the range = 01-05-2005 (Input Date)
To Date of the range = 31-12-2004 (Last Date of the previous year of the input year)This is where I am confused. Is it <b>2004</b> or <u>2005</u>? If it is 2004, then your To date is in the past than your From date which is not possible.
Assuming your input date is in the format of DD-MM-YYYY and internally it is type date field stored as YYYMMDD and the year of the To-Date for the second range is 2005, here is a solution. There is no function module that can do this.
PARAMETERS: P_INPUT LIKE SY-DATUM DEFAULT '20050501'.
DATA: V_BEGIN_OF_YEAR LIKE SY-DATUM,
V_END_OF_YEAR LIKE SY-DATUM.
RANGES: R_RANGE1 FOR SY-DATUM,
R_RANGE2 FOR SY-DATUM.
*-- Prepare the begin of the year of the input
CONCATENATE P_INPUT+0(4)
'01'
'01'
INTO V_BEGIN_OF_YEAR.
*-- Prepare the end of the year of the input
CONCATENATE P_INPUT+0(4)
'12'
'31'
INTO V_END_OF_YEAR.
*-- Prepare the range 1
R_RANGE1-LOW = V_BEGIN_OF_YEAR.
R_RANGE1-HIGH = P_INPUT.
R_RANGE1-OPTION = 'BT'.
R_RANGE1-SIGN = 'I'.
APPEND R_RANGE1.
*-- Prepare the range 2
R_RANGE2-LOW = P_INPUT.
R_RANGE2-HIGH = V_END_OF_YEAR.
R_RANGE2-OPTION = 'BT'.
R_RANGE2-SIGN = 'I'.
APPEND R_RANGE2.Srinivas
Message was edited by: Srinivas Adavi
Please close the thread if answered.
‎2006 Jan 01 11:21 AM
Hi Liat,
from what I could understand you are trying to get the last date of the previous year. try this..
data: w_date type sydatum value '20050501',
w_year(4).
w_year = w_date+0(4).
w_year = w_year - 1.
concatenate w_year '12' '31' into w_date.
write:/ w_date DD/MM/YYYY.
Regards,
Suresh Datti
‎2006 Jan 01 11:22 AM
Hi
I can't understand what you want to get.
If you want the last day of year before:
DATA: YEAR TYPE GJAHR,
DATE TYPE SY-DATUM.
PARAMETERS: P_DATE LIKE SY-DATUM.
YEAR = P_DATE(4) - 1.
CONCATENATE GJAHR '1231'.
But I'm not sure you want this.
Max
Message was edited by: max bianchi
‎2006 Jan 01 11:28 AM
the date 01052005
it's example it can be change all the time
becuase of that i need function to be more dinamic.
‎2006 Jan 01 11:54 AM
so are you confirming that you want to find the last year's last date?
if yes , the solution given by suresh and max is dynamic.
If your requirement is something else, explain it bit clearly.
Regards
Raja
‎2006 Jan 01 6:35 PM
Your example date is 01-05-2005. Can you tell us if it MM-DD-YYYY or DD-MM-YYYY?
From this input you want two ranges
First Range
From Date of the range = 01-01-2005 (Begining date of the year of the input)
To Date of the range = 01-05-005 (Input Date)
Second Range
From Date of the range = 01-05-2005 (Input Date)
To Date of the range = 31-12-2004 (Last Date of the previous year of the input year)This is where I am confused. Is it <b>2004</b> or <u>2005</u>? If it is 2004, then your To date is in the past than your From date which is not possible.
Assuming your input date is in the format of DD-MM-YYYY and internally it is type date field stored as YYYMMDD and the year of the To-Date for the second range is 2005, here is a solution. There is no function module that can do this.
PARAMETERS: P_INPUT LIKE SY-DATUM DEFAULT '20050501'.
DATA: V_BEGIN_OF_YEAR LIKE SY-DATUM,
V_END_OF_YEAR LIKE SY-DATUM.
RANGES: R_RANGE1 FOR SY-DATUM,
R_RANGE2 FOR SY-DATUM.
*-- Prepare the begin of the year of the input
CONCATENATE P_INPUT+0(4)
'01'
'01'
INTO V_BEGIN_OF_YEAR.
*-- Prepare the end of the year of the input
CONCATENATE P_INPUT+0(4)
'12'
'31'
INTO V_END_OF_YEAR.
*-- Prepare the range 1
R_RANGE1-LOW = V_BEGIN_OF_YEAR.
R_RANGE1-HIGH = P_INPUT.
R_RANGE1-OPTION = 'BT'.
R_RANGE1-SIGN = 'I'.
APPEND R_RANGE1.
*-- Prepare the range 2
R_RANGE2-LOW = P_INPUT.
R_RANGE2-HIGH = V_END_OF_YEAR.
R_RANGE2-OPTION = 'BT'.
R_RANGE2-SIGN = 'I'.
APPEND R_RANGE2.Srinivas
Message was edited by: Srinivas Adavi
Please close the thread if answered.
‎2006 Jan 02 4:47 AM
Hi liat,
1 what i undertand is that
u want to SPLIT
and GET ONE WHOLE YEAR
with boundary of 31st December.
2. Try this code (just copy paste)
it will give what u require.
3.
REPORT abc.
PARAMETERS : dt TYPE sy-datum DEFAULT '20050501'.
DATA : d1 TYPE sy-datum.
DATA : d2 TYPE sy-datum.
DATA : d3 TYPE sy-datum.
DATA : yyyy(4) TYPE n.
DATA : y1(4) TYPE n.
*----
yyyy = dt(4).
y1 = yyyy - 1.
*----
CONCATENATE yyyy '0101' INTO d1.
CONCATENATE y1 dt+4(4) INTO d2.
CONCATENATE y1 '1231' INTO d3.
.
*----
WRITE 😕 d1 , ' -
' , dt.
WRITE 😕 d2 , ' -
' , d3.
regards,
amit m.