Monday, November 2, 2009

Date and Time Manipulation

Get The Date/Time 

GET TIME [FIELD <f>].

Synchronizes the date/time on the application server with the time on the database server and refreshes the system fields:
  • SY-UZEIT - Current application server time,
  • SY-DATUM - Current application server date,
  • SY-TIMLO - User’s local time,
  • SY-DATLO - User’s local date,
  • SY-ZONLO - User’s time zone.
If you use the FIELD addition, the variable
is filled with the current time.


Add/Subtract Months To A Date

If you want to add months to a date you can use the function module:

  • MONTH_PLUS_DETERMINE

Example code:

In the DATA section of the code:

DATA: lv_newdate LIKE SY-DATUM,

lv_months TYPE I.


Code using MONTH_PLUS_DETERMINE:

*Synchronize the date/time and refresh the SY-DATUM field.

GET TIME.

*Set the value of lv_months (can be positive or negative).
lv_months = 3.

*Add the months to the date.
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
MONTHS = lv_months
OLDDATE = SY-DATUM
IMPORTING
NEWDATE = lv_newdate.

WRITE:/ 'Old Date was ', SY-DATUM.
WRITE:/ 'New Date is ', lv_newdate.

1 comment:

  1. CASINO ROOM RATES, INFORMATION & TIMES - Mapyro
    View CASINO ROOM 수원 출장마사지 RATES, 원주 출장샵 including the 과천 출장마사지 historical location, 진주 출장마사지 gaming history, photos, hours, contact information, phone 영주 출장안마 number and address.

    ReplyDelete