03-21-2006 10:04 AM - edited 02-04-2024 1:42 AM
Hi,
How can I get the month from a day field in select statement ?
e.g.
select month(erdat), count(*) from vbak group by month(erdat).
Thanks
Wilson
03-21-2006 10:09 AM
data: begin of itab occurs 0.
erdat
count
month
end of itab.
select erdat count(*) from vbak into table itab group by erdat.
loop at itab.
itab-month = itab-erdate+4(2).
modify itab.
endloop.
Message was edited by: kishan negi
03-21-2006 10:10 AM
Hi Wilson,
Try this..
data: w_date type sydatum,
w_month(2).
select erdat from vbak into w_date...
w_month = w_date+4(2).
Regards,
Suresh Datti
03-21-2006 10:14 AM
Hi,
In a select statemant only aggregate expressions like SUM are possible. You need to determine the month between teh select ... endselect
Eddy
03-21-2006 10:24 AM
Hi wilson,
1. How can I get the month from a day field in select statement ?
Directly extracting MONTH from the date field,
is not possible in open sql.
2. U will have to first extract the full date,
in the internal table.
3. After that, u can once again,
loop at the table,
and extract the MONTH from the DATE
in put in extra field.
month = date+4(2).
regards,
amit m.
03-21-2006 10:26 AM
hi wilson,
i think u need to handle the month explicitly into ur table .
just execute the code and see the month field in mm .
hope this helps.
regards,
vikky.
-
tables vbak.
data mm(2).
select-options : so_vbeln for vbak-vbeln.
data: begin of itab occurs 0 ,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
mm(2),
end of itab.
select vbeln erdat
into table itab
from vbak where vbeln in so_vbeln.
loop at itab .
write:/ itab-vbeln,
itab-erdat using edit mask '________'.
mm = itab-erdat+4(2).
write mm.
endloop.
03-21-2006 2:28 PM
Hi,
I use native SQL statement solved the problem. Thanks all!.
Wilson
03-24-2006 7:16 AM
Hi,
Pls don't forget to reward points and close the question if you find the answers useful.
Eddy