2013 Oct 28 2:28 AM
I have got to get a local date from time stamp. Time stamp is of server time. And I have time zone off set. for example
20,130,927,183,711 -04:00
20,130,905,200,845 +02:00
I need to use the time zone offset to get the local date.
I was hoping I will be able to use
CONVERT TIME STAMP my_TSTMP TIME ZONE
tzone INTO DATE calday .
but tzone is expected in the formate of UTC-1 or UTC+2 as such. What will be the best option to get the local date from the information I have in hand. Any suggestion will be very much appreciate.
2013 Dec 05 2:06 PM
Hi Guys,
Thanks for all your replies. My problem was I do not have time zone in the format required. What I ended up doing was, I first offset the timestamp with the time zone information I had.
for example for this record =>
| 20,130,927,183,711 | -04:00 |
I subtract 4 hours from the time stamp. And convert the resulting timestamp (which is now a local date and time ) into date with 'UTC' as a time zone. It gives me a local date.
2013 Oct 28 3:21 AM
2013 Oct 28 4:19 AM
Hi Sophie,
Instead of passing the time of different places directly , just refer table TTZZ . This table contains all the timezone , select the zone for which ur coding and pass it like this.
DATA:
s_tst LIKE tzonref-tstamps,
l_tst LIKE tzonref-tstampl,
tzone LIKE tzonref-tzone,
d TYPE D ,
t TYPE T .
GET TIME STAMP FIELD s_tst. "Short form
GET TIME STAMP FIELD l_tst. "Long form
tzone = 'ALA '. "Specify the time zone here.. refer TTZZ table
CONVERT TIME STAMP l_tst TIME ZONE tzone INTO
DATE d TIME t.
"timestamps - short and long
WRITE: / s_tst TIME ZONE tzone,
/ l_tst TIME ZONE tzone.
WRITE:/ 'After conversion'.
WRITE:/ d, " 12/24/1997
/, (8) t. " 23:55:00
Hope this Helps
Regards,
Sivaganesh
2013 Nov 01 12:05 PM
I should use your solution,and for tzone I should use sy-zynlo.
Best,
Sander
2013 Oct 28 5:13 AM
Hi,
You may try to use the following function module;
CONV_UTIL_ADD_DATE_AND_TIME
Hope that helps.
Regards,
AL
2013 Oct 28 5:37 AM
HI,
DATA : v_timestamp TYPE timestampl,
output TYPE string.
GET TIME STAMP FIELD v_timestamp.
WRITE : v_timestamp.
output = |{ v_timestamp TIMESTAMP = ISO }|."TIMEZONE = 'UTC ' }|.
WRITE / output.
OR this should work for you.
DATA : v_timestamp TYPE timestampl,
v_timestamp1 TYPE timestampl,
output TYPE string,
date TYPE datum,
time TYPE tims.
DATA : time_zone TYPE tzonref-tzone value 'INDIA'.
GET TIME STAMP FIELD v_timestamp.
WRITE : v_timestamp.
CONVERT TIME STAMP v_timestamp TIME ZONE time_zone INTO date date Time time.
write :date DD/MM/YYYY .
WRITE : time.
Thanks & Regards
Priyesh Shah
Message was edited by: Priyesh Shah
2013 Oct 28 6:39 AM
Hi,
Try this:
Regards.
REPORT y_r_eitan_test_09_03 .
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK block02 WITH FRAME .
PARAMETERS: p_date_f TYPE sydatum OBLIGATORY DEFAULT sy-datum .
PARAMETERS: p_time_f TYPE syuzeit OBLIGATORY DEFAULT sy-uzeit .
SELECTION-SCREEN SKIP .
PARAMETERS: p_zone_f TYPE ttzz-tzone OBLIGATORY DEFAULT sy-zonlo .
PARAMETERS: p_zone_t TYPE ttzz-tzone OBLIGATORY DEFAULT 'JAPAN' .
SELECTION-SCREEN END OF BLOCK block02 .
*----------------------------------------------------------------------*
AT SELECTION-SCREEN .
PERFORM at_selection_screen_input .
*----------------------------------------------------------------------*
FORM at_selection_screen_input .
DATA: stamp_1 TYPE timestamp .
CONVERT DATE p_date_f TIME p_time_f
INTO TIME STAMP stamp_1 TIME ZONE p_zone_f .
IF sy-subrc NE 0 .
MESSAGE e212(rd) .
ENDIF .
DATA: dst TYPE c LENGTH 1 .
DATA: datum TYPE sydatum .
DATA: uzeit TYPE syuzeit .
CONVERT TIME STAMP stamp_1 TIME ZONE p_zone_t
INTO DATE datum TIME uzeit DAYLIGHT SAVING TIME dst.
MESSAGE s000(oo) WITH 'Time at' p_zone_t datum uzeit .
ENDFORM . "at_selection_screen_input
*----------------------------------------------------------------------*
2013 Nov 01 8:55 AM
Hi Sophie,
You can try this:
cl_abap_tstmp=>systemtstmp_utc2syst(
EXPORTING utc_tstmp = lv_utc_timestamp
IMPORTING syst_date = lv_system_date " System Date
syst_time = lv_system_time " System Time
).
Regards,
Ashish Kumar
2013 Nov 01 11:50 AM
HI,
Try This..
CONVERT TIME STAMP my_TSTMP TIME ZONE ' UTC '
INTO DATE date TIME time.
Regards,
Charan M.
2013 Nov 01 6:56 PM
Hi,
Charan has the right idea. You need to convert the timestamp you have (e.g. 20,130,927,183,711 -04:00) to UTC and then convert that to the local time zone.
If your report is dependent upon a plant code you may not be able to us sy_zynlo. If this is the case you may need to create a separate configuration table with plant codes and time zones.
Regards,
Steve
2013 Dec 05 2:06 PM
Hi Guys,
Thanks for all your replies. My problem was I do not have time zone in the format required. What I ended up doing was, I first offset the timestamp with the time zone information I had.
for example for this record =>
| 20,130,927,183,711 | -04:00 |
I subtract 4 hours from the time stamp. And convert the resulting timestamp (which is now a local date and time ) into date with 'UTC' as a time zone. It gives me a local date.