<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Converting timestamp from local time to UTC in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257928#M489132</link>
    <description>&lt;P&gt;You have to go through a few conversions, but eventually it works.&lt;/P&gt;&lt;P&gt;* Target: Get latest timestamp from ADSO and give it to variable. But due summertime issues the time gets two hours extra when opening the query. The format in BW is 14 NUMC and cannot easily be converted. So I firstly retrieved the timestamp, than converted into a timestamp added with a timezone. Then converted UTC to CET and than back into the output of the variable. Its a bit a mess, but it works.&lt;BR /&gt;&lt;BR /&gt; IF i_step = 1.&lt;BR /&gt; DATA: max_tstamp TYPE /bi0/oitctlstload,&lt;BR /&gt; time_stamp TYPE timestamp,&lt;BR /&gt; cet TYPE tzonref-tzone VALUE 'CET',&lt;BR /&gt; utc TYPE tzonref-tzone VALUE 'UTC',&lt;BR /&gt; tz TYPE ttzz-tzone,&lt;BR /&gt; date TYPE sydatum,&lt;BR /&gt; time TYPE syuzeit.&lt;BR /&gt;&lt;BR /&gt; SELECT SINGLE MAX( tctlstload ) FROM /bic/azldatmon2 INTO max_tstamp.&lt;BR /&gt;&lt;BR /&gt; tz = 'CET'.&lt;BR /&gt; time_stamp = max_tstamp.&lt;BR /&gt;&lt;BR /&gt; CONVERT TIME STAMP time_stamp TIME ZONE tz&lt;BR /&gt; INTO DATE DATA(dat) TIME DATA(tim)&lt;BR /&gt; DAYLIGHT SAVING TIME DATA(dst).&lt;BR /&gt;&lt;BR /&gt; CONVERT TIME STAMP time_stamp TIME ZONE utc INTO DATE date TIME time.&lt;BR /&gt; CONVERT DATE date TIME time INTO TIME STAMP time_stamp TIME ZONE cet.&lt;BR /&gt;&lt;BR /&gt; max_tstamp = time_stamp.&lt;BR /&gt;&lt;BR /&gt; l_s_range-sign = 'I'.&lt;BR /&gt; l_s_range-opt = 'EQ'.&lt;BR /&gt; l_s_range-low = max_tstamp.&lt;BR /&gt; APPEND l_s_range TO e_t_range.&lt;BR /&gt; ENDIF.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 14:52:32 GMT</pubDate>
    <dc:creator>Blokmeister</dc:creator>
    <dc:date>2021-10-15T14:52:32Z</dc:date>
    <item>
      <title>Converting timestamp from local time to UTC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257920#M489124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a smooth way to convert a timestamp containing local time to UTC time?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONVERT TIME STAMP time_stamp TIME ZONE tz &lt;/P&gt;&lt;P&gt;INTO [DATE dat] [TIME tim] &lt;/P&gt;&lt;P&gt;[DAYLIGHT SAVING TIME dst]. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consideres time_tamp to be UTC time and then tries to convert it to the time zone specified in tz. What I would like to have done is the opposite, to have time_stamp represent the local time and then convert it back to UTC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIA!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Armin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 May 2007 13:00:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257920#M489124</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-25T13:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Converting timestamp from local time to UTC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257921#M489125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Say you have time stamp for local time, split that to date and time

DATA:
  tstamp  TYPE timestamp value '20070525183545',
  d       TYPE D,
  t       TYPE T,
  tstamp_UTC type timestamp.

d =  tstamp+0(8).
t = tstamp+8(8).

CONVERT DATE d TIME t INTO
        TIME STAMP tstamp_UTC TIME ZONE 'UTC'.

write : / tstamp_UTC.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 May 2007 13:07:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257921#M489125</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-25T13:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: Converting timestamp from local time to UTC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257922#M489126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, but it doesn't work.&lt;/P&gt;&lt;P&gt;It just converts from UTC to UTC, ergo nothing changes, the timestamp remains the same!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also &lt;/P&gt;&lt;P&gt;d =  tstamp+0(8).&lt;/P&gt;&lt;P&gt;t = tstamp+8(8).&lt;/P&gt;&lt;P&gt;is not possible since you can't reference timestamp like that!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 May 2007 13:35:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257922#M489126</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-25T13:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Converting timestamp from local time to UTC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257923#M489127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Armin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just turn your statement and you will be fine&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: date TYPE sydatum VALUE '20070525',
      time TYPE syuzeit VALUE '173030',
      cet  TYPE tzonref-tzone VALUE 'CET',
      utc  TYPE tzonref-tzone VALUE 'UTC',
      tstp TYPE timestamp.

CONVERT DATE date TIME time INTO TIME STAMP tstp TIME ZONE cet .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The output will be 15:30:30 at 25th of May 2007.&lt;/P&gt;&lt;P&gt;I used CET as example, just use the timezone your date is representing. The result is formatted as UTC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually if you only have the timestamp, for this solution you have to convert it into date/time first.&lt;/P&gt;&lt;P&gt;Use &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CONVERT TIME STAMP tstp TIME ZONE utc INTO DATE date TIME time.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to do so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Timo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 May 2007 15:12:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257923#M489127</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-25T15:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Converting timestamp from local time to UTC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257924#M489128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Time for the helpful answer!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2007 07:33:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257924#M489128</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-29T07:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Converting timestamp from local time to UTC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257925#M489129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Timo, sorry &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2007 07:34:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257925#M489129</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-29T07:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Converting timestamp from local time to UTC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257926#M489130</link>
      <description>&lt;P&gt;Hi Timo, thank you very much for your valuable post!&lt;BR /&gt;&lt;BR /&gt;As far as I have understood, if one has only a timestamp, we have to generate Date und Time first (with the last stated CONVERT instruction) and then convert again with the first stated CONVERT instruction. Is this right?&lt;/P&gt;&lt;P&gt;When converting for the second time, does ABAP interpret Date and Time that way that it already has been converted to UTC before? What I mean is: Don't we convert twice with UTC, so that the 2nd conversion considers a local time?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 14:41:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257926#M489130</guid>
      <dc:creator>ThomasMundt</dc:creator>
      <dc:date>2019-05-17T14:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Converting timestamp from local time to UTC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257927#M489131</link>
      <description>&lt;A href="https://answers.sap.com/users/295585/thmundt.html"&gt;Thomas Mundt&lt;/A&gt; I doubt that "Timo"/"Former member" would answer after 12 years. Please ask a Question instead. Based on your question, you might receive more adequate answers, i.e. for instance based on the class CL_ABAP_TSTMP.</description>
      <pubDate>Mon, 20 May 2019 07:05:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257927#M489131</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-05-20T07:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Converting timestamp from local time to UTC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257928#M489132</link>
      <description>&lt;P&gt;You have to go through a few conversions, but eventually it works.&lt;/P&gt;&lt;P&gt;* Target: Get latest timestamp from ADSO and give it to variable. But due summertime issues the time gets two hours extra when opening the query. The format in BW is 14 NUMC and cannot easily be converted. So I firstly retrieved the timestamp, than converted into a timestamp added with a timezone. Then converted UTC to CET and than back into the output of the variable. Its a bit a mess, but it works.&lt;BR /&gt;&lt;BR /&gt; IF i_step = 1.&lt;BR /&gt; DATA: max_tstamp TYPE /bi0/oitctlstload,&lt;BR /&gt; time_stamp TYPE timestamp,&lt;BR /&gt; cet TYPE tzonref-tzone VALUE 'CET',&lt;BR /&gt; utc TYPE tzonref-tzone VALUE 'UTC',&lt;BR /&gt; tz TYPE ttzz-tzone,&lt;BR /&gt; date TYPE sydatum,&lt;BR /&gt; time TYPE syuzeit.&lt;BR /&gt;&lt;BR /&gt; SELECT SINGLE MAX( tctlstload ) FROM /bic/azldatmon2 INTO max_tstamp.&lt;BR /&gt;&lt;BR /&gt; tz = 'CET'.&lt;BR /&gt; time_stamp = max_tstamp.&lt;BR /&gt;&lt;BR /&gt; CONVERT TIME STAMP time_stamp TIME ZONE tz&lt;BR /&gt; INTO DATE DATA(dat) TIME DATA(tim)&lt;BR /&gt; DAYLIGHT SAVING TIME DATA(dst).&lt;BR /&gt;&lt;BR /&gt; CONVERT TIME STAMP time_stamp TIME ZONE utc INTO DATE date TIME time.&lt;BR /&gt; CONVERT DATE date TIME time INTO TIME STAMP time_stamp TIME ZONE cet.&lt;BR /&gt;&lt;BR /&gt; max_tstamp = time_stamp.&lt;BR /&gt;&lt;BR /&gt; l_s_range-sign = 'I'.&lt;BR /&gt; l_s_range-opt = 'EQ'.&lt;BR /&gt; l_s_range-low = max_tstamp.&lt;BR /&gt; APPEND l_s_range TO e_t_range.&lt;BR /&gt; ENDIF.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 14:52:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-timestamp-from-local-time-to-utc/m-p/2257928#M489132</guid>
      <dc:creator>Blokmeister</dc:creator>
      <dc:date>2021-10-15T14:52:32Z</dc:date>
    </item>
  </channel>
</rss>

