Get months from a date range comparing event date
Hi All,
Below is the data
CREATE TABLE #Coverage(
EmployeeID INT,
EmployeeName VARCHAR(20),
CoverageName VARCHAR(50),
CoverageAmount Decimal,
CoveredBy VARCHAR(20),
EventDate DATETIME,
CoverageStartDate DATETIME,
CoverageEndDate DATETIME
INSERT INTO #coverage VALUES (8,'Lara','Employee + Children',213.60,'EmployeeContribution','2013-10-01','2013-10-01','2014-05-31'),
(8,'LAra','Employee + Children', 606.31 ,'CompanyContribution' ,'2013-10-01','2013-10-01','2014-05-31'),
(8,'LAra','Employee Only' ,0.00 ,'EmployeeContribution' ,NULL ,'2013-06-01','2014-05-31'),
(8,'LAra','Employee Only' ,431.55 ,'CompanyContribution' ,NULL ,'2013-06-01','2014-05-31'),
(8,'LAra','Employee Only' ,81.42 ,'EmployeeContribution' ,NULL ,'2012-06-01','2013-05-31'),
(8,'LAra','Employee Only' ,420.93 ,'CompanyContribution' ,NULL ,'2012-06-01','2013-05-31')
SELECT * FROM #Coverage
drop table #coverage
and expected out put for the year 2013
EmployeeID
EmployeeName
CoverageName
CoverageAmount
CoveredBy
Month
Year
8
Lara
Employee Only
81
Employee Contibution
1
2013
8
Lara
Employee Only
421
Company Contribution
1
2013
8
Lara
Employee Only
81
Employee Contibution
2
2013
8
Lara
Employee Only
421
Company Contribution
2
2013
8
Lara
Employee Only
81
Employee Contibution
3
2013
8
Lara
Employee Only
421
Company Contribution
3
2013
8
Lara
Employee Only
81
Employee Contibution
4
2013
8
Lara
Employee Only
421
Company Contribution
4
2013
8
Lara
Employee Only
81
Employee Contibution
5
2013
8
Lara
Employee Only
421
Company Contribution
5
2013
8
Lara
Employee Only
81
Employee Contibution
6
2013
8
Lara
Employee Only
421
Company Contribution
6
2013
8
Lara
Employee Only
81
Employee Contibution
7
2013
8
Lara
Employee Only
421
Company Contribution
7
2013
8
Lara
Employee Only
81
Employee Contibution
8
2013
8
Lara
Employee Only
421
Company Contribution
8
2013
8
Lara
Employee Only
81
Employee Contibution
9
2013
8
Lara
Employee Only
421
Company Contribution
9
2013
8
Lara
Employee +Children
214
Employee Contibution
10
2013
8
Lara
Employee +Children
606
Company Contribution
10
2013
8
Lara
Employee +Children
214
Employee Contibution
11
2013
8
Lara
Employee +Children
606
Company Contribution
11
2013
8
Lara
Employee +Children
214
Employee Contibution
12
2013
8
Lara
Employee +Children
606
Company Contribution
12
2013
Can any one help me out with this.
Thanks!
This gives your resultset.
I've added the cte to give a newenddate because your dataset doesn't close off the previous one in all cases and gave duplicates - you can remove this if it is a mistake in the data. Also you would need to add the employee to the partition to run on multiple
employees.
declare
@Coverage TABLE (
EmployeeID
INT,
EmployeeName
VARCHAR(20),
CoverageName
VARCHAR(50),
CoverageAmount
Decimal,
CoveredBy
VARCHAR(20),
EventDate
DATETIME,
CoverageStartDate
DATETIME,
CoverageEndDate
DATETIME
INSERT
INTO @Coverage
VALUES (8,'Lara','Employee + Children',213.60,'EmployeeContribution','2013-10-01','2013-10-01','2014-05-31'),
(8,'LAra','Employee
+ Children', 606.31
,'CompanyContribution'
,'2013-10-01','2013-10-01','2014-05-31'),
(8,'LAra','Employee
Only'
,0.00 ,'EmployeeContribution'
,NULL ,'2013-06-01','2014-05-31'),
(8,'LAra','Employee
Only'
,431.55
,'CompanyContribution'
,NULL ,'2013-06-01','2014-05-31'),
(8,'LAra','Employee
Only'
,81.42 ,'EmployeeContribution'
,NULL ,'2012-06-01','2013-05-31'),
(8,'LAra','Employee
Only'
,420.93
,'CompanyContribution'
,NULL ,'2012-06-01','2013-05-31')
SELECT
* FROM
@Coverage
;with
ctee1 as
select
*, seq
= row_number()
over (partition
by coveredby
order by coveragestartdate)
from
@Coverage
,ctee
as
select
c1.*,
newenddte = coalesce(c2.coveragestartdate-1,
c1.coverageenddate)
from
ctee1 c1
left
join ctee1
c2
on
c1.coveredby
= c2.coveredby
and
c1.seq
= c2.seq-1
cte1 as
select
dtestrt =
convert(datetime,'20130101'),
dteend =
convert(datetime,'20131201')
,cte
as
select
dtestrt =
cte1.dtestrt,
dteend =
dateadd(mm,1,cte1.dtestrt)-1,
mth =
month(cte1.dtestrt),
yr =
year(cte1.dtestrt)
from cte1
union
all
select
dtestrt =
dateadd(mm,1,cte.dtestrt),
dteend =
dateadd(mm,2,cte.dtestrt)-1,
mth =
month(dateadd(mm,1,cte.dtestrt)),
yr =
year(dateadd(mm,1,cte.dtestrt))
from cte,
cte1 where
cte.dtestrt
< cte1.dteend-1
select
c.EmployeeID,
c.EmployeeName,
c.CoverageName,
c.CoverageAmount,
c.CoveredBy,
cte.mth,
cte.yr,
cte.dtestrt,
cte.dteend
from
cte
join
ctee c
on
cte.dtestrt
<= c.newenddte
and cte.dteend
>= c.CoverageStartDate
order
by c.EmployeeID,
cte.dtestrt
Similar Messages
-
Get month from a date column ina table
Hi
I have a table that consists of one column of date data type. For example it stores mm/dd/yyyy.
I want to get all the records from this table where month = 12. for the year 2000.
I saw the extract function. However That is used while selecting. How can I give a condition in where clause:
select date_col
from dates-table
where <get month for date_col> = december or 12
and year = 2000???Ok that certainy helps.
This is what I am trying to do.
I have a procedure to which I am passing the date_param (of date data type).
declare
my_month date;
begin
select to_char(date_param,'MM') into my_month from dual;
select date_col from dates-table where to_char(date_col,'mm')= my_month and some_indicator='Y';
end;This will return me one date where the indicator is set to Y.
For example date_param is passed as 01/01/2000.
select to_char('01/01/2000','MM') from dual;I get the error when I run the above. I get an error saying invalid number. -
Get the month from a date column with the calculated column
I am trying to get the month from a date field with the help of calculated column. However I get this syntax error whenever I want to submit the formula:
Error
The formula contains a syntax error or is not supported.
the default language of our site is German and [datum, von] is a date field.Hi,
I have created two columns
Current MM-YY
Calculated (calculation based on other columns)
Today
Date and Time
Current MM-YY is calculated value with formula as
=TEXT(Today,"mmmm")
But the output shows as December instead of May.
I have tried =TEXT([Datum, von];"mmmm") but no help.
I am trying to populated the column automatically with current month..ex: if its May the field should show May, next month it should show June an so on.
Any kind help is grateful.
Regards,
Pradeep -
How to get name of the month from current date.
Hi,
How to get the name of the month from current date.
Thanks,
SenthilSethil,
Use your date(let us say Date1) instead of sy-datum.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
IMPORTING
RETURN_CODE =
TABLES
MONTH_NAMES = itab_month
EXCEPTIONS
MONTH_NAMES_NOT_FOUND = 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.
READ TABLE itab_month
WITH KEY MNR = date1+4(2).
itab_month-LTX will contain the value you are looking for
Good luck
Raghava -
I want to get the month from a date. I know how I can get it from today's date, but let's say I have a pre-defined date like:
String myDate = "11/15/89";How can I get "November" from that?
Edited by: TheTitans on Feb 12, 2009 4:56 PMSimpleDateFormat[http://java.sun.com/docs/books/tutorial/i18n/format/simpleDateFormat.html]
~ -
Get last august month from current date
Hi,
I need to get last august month from current date.
e.g if current date is 1-OCT-2013 need to get last August date i.e.1-AUG-2013
e.g. if current date is 1-MAY-2013 need to get last August date i.e.1-AUG-2012Something like this?
SQL> WITH table_x AS(
2 SELECT SYSDATE dt from dual UNION ALL
3 SELECT TO_DATE('20-05-2013','dd-mm-yyyy') from dual
4 )
5 --
6 ---
7 --
8 SELECT dt,
9 CASE
10 WHEN (dt >= Add_Months(TRUNC(dt,'YEAR'),7)) THEN
11 Add_Months(TRUNC(dt,'YEAR'),7)
12 WHEN (dt < Add_Months(TRUNC(dt,'YEAR'),7)) THEN
13 Add_Months(TRUNC(dt,'YEAR'),7) - 365
14 END cs
15 FROM table_x;
DT CS
24-OCT-13 01-AUG-13
20-MAY-13 01-AUG-12 -
Getting month from Calendar Year/month...
Dear All,
I'm using Webi 4.0 SP6 and I need to get months from Calendar Year/Month which I'm using in a query to display on Cross Table along with brands.
1. Is there any standard function available to convert Calandar Year/Month (Say: 201401 to Jan or January).?
2. How can I get month from Calendar Year/Month for cross-table?
I will appreciate your reply.
Many Thanks!!!
Tariq AshrafTariq,
Month = Substr([Cal Year];5;2)
Month Name = If Substr([Cal Year];5;2) = "01" then "Jan"
else if Substr([Cal Year];5;2) = "02" then "Feb"
else if Substr([Cal Year];5;2) = "03" then "Mar"
else if Substr([Cal Year];5;2) = "04" then "Apr"
else if Substr([Cal Year];5;2) = "05" then "May"
else if Substr([Cal Year];5;2) = "06" then "Jun"
else if Substr([Cal Year];5;2) = "07" then "Jul"
else if Substr([Cal Year];5;2) = "08" then "Aug"
else if Substr([Cal Year];5;2) = "09" then "Sep"
else if Substr([Cal Year];5;2) = "10" then "Oct"
else if Substr([Cal Year];5;2) = "11" then "Nov" else "Dec"
If you have data like 20140101 then simply use = formatdate([Date];"Mon") -
URL in lieu PH consumed within 3 months from the date of PH
Hi friends
I achieved Unrecorded leave in lieu of PH,through writing PCR but i am having another doubt..This URL in lieu of PH has to be consumed within 3 months from the date of public holiday,how to achieve this??any suggestions from u friends???
Thanks&best regds
ShailaI have asked a moderator to provide assistance, they will post an invite on this thread.
They are the only BT employees on this forum, and are a UK based team of people, who take personal ownership of your problem.
Once you get a reply, make sure that you are logged into the forum, then click on their name, you will see a screen like this. Click on the link as shown below.
Please do not send them a personal message, as they cannot deal with service issues that way.
For your own security, do not post any personal details, on this forum. That includes any tracking number you are give.
They will respond either by phone or e-mail, when its your turn in the queue.
Please use the tracked e-mail, to reply, not via the forum. Thanks
This is the form you should see when you click on the link. If you do not see this form, then you have selected the wrong link.
When you submit the form, you will receive an enquiry number, so please keep a note of it
There are some useful help pages here, for BT Broadband customers only, on my personal website.
BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones. -
Subtracting months from current date
how to subtract months from current date in mysql
You are in an Oracle forum, so the Oracle answer is: use add_months(sysdate,-2) to subtract two months from the current date.
Regards,
Rob. -
How to get previous 2 months from current date in a dropdown?
Hello Experts ,
In the application which I am developing, there is a requirement wherein , I want to Populate current month and previous two month in a drop down depending upon today's date. please help.
Thanks & Regards,
Pratbha ShuklaThe internal format for dates is yyyymmdd. Therefore you can just grab the month value from the date:
data lv_month type FCMNR.
lv_month = lv_date+4(2).
Just subtract from the month to get the two previous.
data lv_previous1 type FCMNR.
data lv_previous2 type FCMNR.
if lv_month = 1.
lv_previous1 = '12'.
else.
lv_previous1 - lv_month - 1.
endif.
if lv_previous1 = 1.
lv_previous2 = '12'.
else.
lv_previous2 - lv_previous1 - 1.
endif.
Then do your lookup for the month name by reading the table returned from function module MONTH_NAMES_GET. -
Function to list the month from a date range?
I would like to know what the function is that would take a look at a date range, and extract the month name
Here is how I would like it to come out:Hello
The following sample tables are along your original scheme using month name to filter the data.
2014 (excerpt)
A1 month
A2 =MONTHNAME(MONTH(B2))
A3 =MONTHNAME(MONTH(B3))
A4 =MONTHNAME(MONTH(B4))
B1 date
B2 2013-01-15
B3 2013-01-20
B4 2013-01-27
C1 category
C2 A
C3 B
C4 C
D1 amount
D2 100
D3 50
D4 20
January
A1 category
A2 A
A3 B
A4 C
A5 D
A6 E
A7 F
A8 G
A9 H
B1 totals
B2 =SUMIFS(2014::D,2014::A,C$1,2014::C,A2)
B3 =SUMIFS(2014::D,2014::A,C$1,2014::C,A3)
B4 =SUMIFS(2014::D,2014::A,C$1,2014::C,A4)
B5 =SUMIFS(2014::D,2014::A,C$1,2014::C,A5)
B6 =SUMIFS(2014::D,2014::A,C$1,2014::C,A6)
B7 =SUMIFS(2014::D,2014::A,C$1,2014::C,A7)
B8 =SUMIFS(2014::D,2014::A,C$1,2014::C,A8)
B9 =SUMIFS(2014::D,2014::A,C$1,2014::C,A9)
C1 January
C2
C3
C4
C5
C6
C7
C8
C9
Notes.
Formula in January::B2 can be filled down across B2:B9.
The target month name is defined in January::C1.
February table is the same as January table except for the value in C1.
And the following sample tables are using date per se instead of month name to filter the data. In this scheme, you don't need month column in source table but the retrieving formulae in destination table become more complex.
2014 (excerpt)
A1 date
A2 2013-01-15
A3 2013-01-20
A4 2013-01-27
B1 category
B2 A
B3 B
B4 C
C1 amount
C2 100
C3 50
C4 20
January
A1 category
A2 A
A3 B
A4 C
A5 D
A6 E
A7 F
A8 G
A9 H
B1 totals
B2 =SUMIFS(2014::C,2014::B,A2,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B3 =SUMIFS(2014::C,2014::B,A3,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B4 =SUMIFS(2014::C,2014::B,A4,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B5 =SUMIFS(2014::C,2014::B,A5,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B6 =SUMIFS(2014::C,2014::B,A6,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B7 =SUMIFS(2014::C,2014::B,A7,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B8 =SUMIFS(2014::C,2014::B,A8,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B9 =SUMIFS(2014::C,2014::B,A9,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
C1 2013-01-01
C2
C3
C4
C5
C6
C7
C8
C9
Notes.
Formula in January::B2 can be filled down across January::B2:B9.
The target month is defined in January::C1, which can be any date in target month, e.g., 2013-01-01, 2013-01-20, etc. The formulae in B will retrieve data with date in range: 2013-01-01 <= [date] <= 2013-01-31.
February table is the same as January table except for the value in C1.
Tables are built in Numbers v2.
Hope this may help,
H
EDIT: Replaced the last table with the correct one. (Formulae in B are correct) -
How to - get first DAY of the month from the date ?
Hi
pls helphi,
data : DAYNR LIKE HRVSCHED-DAYNR,
DAYTXT LIKE HRVSCHED-DAYTXT.
data langu like sy-langu value 'EN'.
Parameters PDATE LIKE SY-DATUM.
PDATE+6(02) = '01'.
CALL FUNCTION 'RH_GET_DATE_DAYNAME'
EXPORTING
LANGU = LANGU
DATE = PDATE
CALID =
IMPORTING
DAYNR = DAYNR
DAYTXT = DAYTXT
DAYFREE =
EXCEPTIONS
NO_LANGU = 1
NO_DATE = 2
NO_DAYTXT_FOR_LANGU = 3
INVALID_DATE = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE :/ PDATE, DAYNR, DAYTXT.
(OR)
Try..
DATA:DAYNR LIKE HRVSCHED-DAYNR,
DAYTXT LIKE HRVSCHED-DAYTXT,
DAYFREE LIKE HRVSCHED-NODAY.
DATA:LANGU LIKE SY-LANGU ,
DATE LIKE SY-DATUM,
CALID LIKE P1027-CALID VALUE 'US'.
date = sy-datum.
date+6(2) = 01. "----->to get the first day .
*first day of the month
write:/ 'First date of the month', date.
*Day name
CALL FUNCTION 'RH_GET_DATE_DAYNAME'
EXPORTING
langu = SY-LANGU
date = DATE
CALID = CALID
IMPORTING
DAYNR = DAYNR
DAYTXT = DAYTXT
DAYFREE = DAYFREE
EXCEPTIONS
NO_LANGU = 1
NO_DATE = 2
NO_DAYTXT_FOR_LANGU = 3
INVALID_DATE = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE:/ DAYTXT.
Don't forget to reward if useful.... -
Hi All,
I have two date characteristics Start date and Pricing date. now i need to create a query, showing the month of start date and Pricing in two seperate columns.
suppose start date = 08/15/2007
pricing date = 10/20/2007
then in the query i need to have two columns with output
Start data month... |.........pricing date month
..........08..............|......... 10
Any advice on how to acheive this.
Thanks
KumarTry this
DATA: L_S_RANGE TYPE RSR_S_RANGESID.
DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.
CASE I_VNAM.
WHEN 'yourvar'.
IF I_STEP=2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'variablename where user entry'.
CLEAR L_S_RANGE.
L_S_RANGE-LOW = LOC_VAR_RANGE-LOW+4(2). "YYYYMMDD
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF. -
Calculations for 6 months from todays date
Need to calculate the total of all the months starting from today's date for the next 6 months from the current date.
For ex
Month Total
01.07.2008 10
01.08.2008 20
01.09.2008 50
01.10.2008 72
01.11.2008 85
01.12.2008 15
Please advice how to work on this.
Can we use ranges?
Thanks in advance.Hi dolly,
Ref this code.....
TYPE-POOLS :
slis.
TABLES :
pernr.
INFOTYPES :
0000,
0001,
0002.
TYPES :
BEGIN OF t_final,
srlno TYPE i, "Serial No
pernr TYPE p0000-pernr, "Employee No
vorna TYPE p0002-vorna, "First Name
nachn TYPE p0002-nachn, "Last Name
btrtl TYPE p0001-btrtl, "PERSONAL SUB AREA / SEGMENT
btext TYPE t001p-btext, " SEGMENT DESC
begda TYPE p0000-begda, " JOINING DATE
pdate TYPE p0000-begda, " Probation period date.
END OF t_final,
BEGIN OF t_t001p,
btrtl TYPE t001p-btrtl,
btext TYPE t001p-btext,
END OF t_t001p.
DATA :
v_year(4) TYPE n,
v_year1 TYPE i,
count TYPE i,
v_mont(2) TYPE n,
v_dt(2) TYPE n,
v_date(8),
it_final TYPE STANDARD TABLE OF t_final,
it_temp TYPE STANDARD TABLE OF t_final,
it_t001p TYPE STANDARD TABLE OF t_t001p,
wa_t001p TYPE t_t001p,
wa_temp TYPE t_final,
wa_final TYPE t_final.
ALV Grid Declarations *
DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF it_fieldcat,
wa_layout TYPE slis_layout_alv,
it_sortcat TYPE slis_t_sortinfo_alv,
wa_sortcat LIKE LINE OF it_sortcat.
START-OF-SELECTION.
PERFORM fill_itabs.
GET pernr.
rp-provide-from-frst p0000 space '18000101' '99991231'.
IF pnp-sw-found = 1.
IF p0000-stat2 = 3. " Checking for status.
MOVE :
p0000-begda TO wa_temp-begda,
p0000-pernr TO wa_temp-pernr.
rp-provide-from-last p0001 space pnpbegda pnpendda.
IF pnp-sw-found = 1.
MOVE :
p0001-btrtl TO wa_temp-btrtl.
CLEAR : wa_t001p.
READ TABLE it_t001p INTO wa_t001p WITH KEY btrtl = wa_temp-btrtl.
IF sy-subrc = 0.
MOVE : wa_t001p-btext TO wa_temp-btext.
ENDIF.
ENDIF.
rp-provide-from-last p0001 space pnpbegda pnpendda.
IF pnp-sw-found = 1.
MOVE :
p0002-vorna TO wa_temp-vorna,
p0002-nachn TO wa_temp-nachn.
ENDIF.
APPEND wa_temp TO it_temp.
CLEAR : wa_temp.
ENDIF. "if p0000-stat2 = 3.
ENDIF. "if pn-sw-found = 1.
END-OF-SELECTION.
PERFORM process_data.
PERFORM build_catalog.
PERFORM display_data.
*& Form PROCESS_DATA
text
--> p1 text
<-- p2 text
FORM process_data .
LOOP AT it_temp INTO wa_temp.
IF wa_temp-begda+4(2) > 6.
v_year = wa_temp-begda(4) + 1.
v_mont = wa_temp-begda+4(2) + 6.
v_dt = wa_temp-begda+6(2).
IF WA_TEMP-BEGDA+4(2) = '08'.
IF wa_temp-begda+6(2) = '29' OR
wa_temp-begda+6(2) = '30' OR
wa_temp-begda+6(2) = '31'.
v_dt = '28'.
ENDIF.
ENDIF.
IF v_mont > 12.
v_mont = v_mont - 12.
CONCATENATE v_year v_mont v_dt INTO v_date.
MOVE : v_date TO wa_temp-pdate.
ENDIF.
ELSE.
v_mont = wa_temp-begda+4(2) + 6.
CONCATENATE wa_temp-begda(4) v_mont wa_temp-begda6(2) INTO v_date.
wa_temp-pdate = v_date.
ENDIF.
MODIFY it_temp FROM wa_temp .
CLEAR : v_date, v_year, v_mont.
ENDLOOP.
LOOP AT it_temp INTO wa_temp WHERE pdate BETWEEN pnpbegda AND pnpendda.
MOVE : wa_temp-pernr TO wa_final-pernr,
wa_temp-vorna TO wa_final-vorna,
wa_temp-nachn TO wa_final-nachn,
wa_temp-begda TO wa_final-begda,
wa_temp-btrtl TO wa_final-btrtl,
wa_temp-btext TO wa_final-btext.
CASE wa_temp-pdate+4(2).
WHEN '04' OR '06' OR '09' OR '11'.
IF wa_temp-pdate+6(2) > '30'.
CONCATENATE wa_temp-pdate(4) wa_temp-pdate4(2) '30' INTO v_date.
MOVE : v_date TO wa_final-pdate.
ELSE.
MOVE wa_temp-pdate TO wa_final-pdate.
ENDIF.
WHEN '02'.
v_year1 = wa_temp-pdate+(4) MOD 4.
IF v_year1 = 0 AND wa_temp-pdate+6(2) > '29'.
CONCATENATE wa_temp-pdate(4) wa_temp-pdate4(2) '29' INTO v_date.
MOVE : v_date TO wa_final-pdate.
ELSEIF v_year1 NE 0 AND wa_temp-pdate+6(2) > '28'.
CONCATENATE wa_temp-pdate(4) wa_temp-pdate4(2) '28' INTO v_date.
MOVE : v_date TO wa_final-pdate.
ELSE.
MOVE wa_temp-pdate TO wa_final-pdate.
ENDIF.
WHEN OTHERS.
MOVE wa_temp-pdate TO wa_final-pdate.
ENDCASE.
count = count + 1.
MOVE : count TO wa_final-srlno.
APPEND wa_final TO it_final.
CLEAR : wa_final, v_year1 , v_date.
ENDLOOP.
ENDFORM. " PROCESS_DATA
*& Form BUILD_CATALOG
FORM build_catalog .
DEFINE m_fieldcat.
add 1 to wa_fieldcat-col_pos.
wa_fieldcat-fieldname = &1.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-seltext_m = &2.
wa_fieldcat-outputlen = &3.
append wa_fieldcat to it_fieldcat.
END-OF-DEFINITION.
m_fieldcat 'SRLNO' 'S No' '8' .
m_fieldcat 'PERNR' 'Employee No' '15'.
m_fieldcat 'VORNA' 'First Name' '15' .
m_fieldcat 'NACHN' 'Last Name' '15' .
m_fieldcat 'BTRTL' 'Segment' '15' .
m_fieldcat 'BTEXT' 'Segment Desc' '15' .
m_fieldcat 'BEGDA' 'Date of Joining' '15'.
m_fieldcat 'PDATE' 'Probation End Date' '15' .
ENDFORM. " BUILD_CATALOG
*& Form DISPLAY_DATA
FORM display_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = it_fieldcat
it_sort = it_sortcat
TABLES
t_outtab = it_final.
ENDFORM. " DISPLAY_DATA
*& Form FILL_ITABS
FORM fill_itabs .
SELECT btrtl
btext
FROM t001p
INTO TABLE it_t001p.
ENDFORM. " FILL_ITABS -
Defaulting date 3 months from present date
HI!
In my selection screen in my report I need to default a
selection option to a future date which is 3 months from the
present date. Can anyone tell me whats the way to do this so
that I can add 3 montsh from the present date and default it in my selection screen.
example : if we consider todays date then we need to
default that date to 9th of september 2008 so it keeps of
changing everyday as dates proceed.
ThanksCheck the below program :
REPORT ZTEST78 .
data v_fdate type d.
CALL FUNCTION 'HR_PSD_DATES_ADD_MONTHS'
EXPORTING
V_DATE = sy-datum
V_MONTHS = 3
IMPORTING
E_DATE = v_fdate
EXCEPTIONS
NOT_POSITIVE = 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.
write:/ v_fdate.
do not add 90 days ,some months may have 31 or 29 or 28,you will not get exact calculation,so use FM 'HR_PSD_DATES_ADD_MONTHS'
Thanks
Seshu
Thanks
Seshu
Maybe you are looking for
-
Hi, Here is a snippet of some sample code. The commented query works and I recieve my data. The setString sets the string but the query fails. Am I missing something. Bear in mind that the connection is fine etc. Just that the commented select statem
-
Can not report data thru PI sheet
Dear Gurus, I have configured basic PI sheet. I have selected few characteristics like start date, end date, qty to be confirmed... I can see PI sheet in CO58/CO60. But the characteristics are not editable. How can I report the data using PI sheet? S
-
Create Multiple dynamic Node in Web Dynpro Abap
Hi Friends, I need your help.My object is to create Multiple dynamic dropdown UI element.I am able to create this dynamic Dropdown element. But i need to assign default different values to this dropdown elements.So i created dynamic nodes for e
-
We want to create a policy set that hits on a endpoint identity group. An endpoint identity group contains a bunge mac-address which we can't filter out with radius user-name match which work fine for a vendor hit. Does anybody got an idea of this is
-
PRODUCTION ISSUE - Receivemail java procedure
Hi guys I have this java program below, this program receives mail from a user general mailbox and displays it as in a Java Front End System as a request. Users are able to attach any type of attachments and even embedded emails. My java program work