<?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: How can I convert a timestamp into another timezone in Connectivity &amp; Data Prep</title>
    <link>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823116#M1052</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suggest you tried it first in a qv textbox with one or two original values manually and if this worked it should work in script, too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Dec 2014 13:33:28 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2014-12-15T13:33:28Z</dc:date>
    <item>
      <title>How can I convert a timestamp into another timezone</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823113#M1049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For performance and storage reasons we store timestamp values in two separate columns as written here: &lt;A _jive_internal="true" href="https://community.qlik.com/blogs/qlikviewdesignblog/2013/07/23/the-master-time-table" title="http://community.qlik.com/blogs/qlikviewdesignblog/2013/07/23/the-master-time-table"&gt;http://community.qlik.com/blogs/qlikviewdesignblog/2013/07/23/the-master-time-table&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data we need to load is stored inside a QVD file (incremental load into those QVD files, and afterwards load all data with a query from those files). The QVD contain two column "Date" and "Time" with a split timestamp information. The data contains UTC timestamps in e. g. the following style&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Time (in UTC)&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Date (in UTC)&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;11:35&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/12/2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;13:56&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/12/2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;and so on...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inow want to shift data to match a specific timezone but keep the QVD files unchanged (e. g. shift to GMT-10:00 to keep it easy).&lt;/P&gt;&lt;P&gt;Because the time and date information is splitted I need to combine them again.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timestamp#("Date" &amp;amp; ' ' &amp;amp; "Time", 'YYYY/MM/DD hh:mm') AS "Parsed Timestamp",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Should do the trick. And the datamodell shows it works: &lt;SPAN style="font-family: courier new,courier;"&gt;"12/12/2014 11:35"&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; is shown in the table preview.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H3&gt;The load script:&lt;/H3&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD *,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timestamp#("Date" &amp;amp; ' ' &amp;amp; "Time", 'YYYY/MM/DD hh:mm') AS "Parsed Timestamp",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date#("Date" &amp;amp; ' ' &amp;amp; "Time", 'YYYY/MM/DD hh:mm') AS "Parsed Date",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConvertToLocalTime(Timestamp#("Date" &amp;amp; ' ' &amp;amp; "Time", 'YYYY/MM/DD hh:mm'), 'UTC-10:00') AS "Shifted Timestamp",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConvertToLocalTime(Date#("Date" &amp;amp; ' ' &amp;amp; "Time", 'YYYY/MM/DD hh:mm'), 'UTC-10:00') AS "Shifted Date",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConvertToLocalTime('2007-11-10 23:59:00','UTC-10:00') AS "example 1 from documentation",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConvertToLocalTime(UTC(),&lt;SPAN style="font-family: courier new,courier;"&gt;'UTC-10:00'&lt;/SPAN&gt;) AS "example 2 from documentation"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM '$(QvdConnection)/someQvdFile.qvd' (qvd)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE "Application ID"='$(ApplicationId)';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="script_token" style="margin-top: 0.7em; margin-bottom: 0.8em; font-family: monospace; font-weight: bold; color: #444444; font-size: 13px; font-style: normal; text-align: start; text-indent: 0px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;Table preview&lt;/H3&gt;&lt;P&gt;The output in the datamodell table preview will look like this&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Time&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Date&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Parsed Timestamp&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Parsed Date&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Shifted Timestamp&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Shifted Date&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;example 1 from documentation&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;example 2 from documentation&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;11:35&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/12/2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/12/2014 11:35&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/12/2014 11:35&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;-&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;-&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;11/10/2007 1:59:00 PM&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/12/2014 2:46:13 AM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;13:56&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/12/2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/12/2014 13:56&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/12/2014 13:56&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;-&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;-&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;11/10/2007 1:59:00 PM&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12/12/2014 2:46:13 AM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Timestamp# and Date# methods return something, and it looks correct (although the AM information is not there).&lt;/P&gt;&lt;P&gt;The ConvertToLocalTime method does work with UTC-10:00, but with GMT-10:00 you get the same results (the examples on in the documentation work).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Why does the ConverToLocalTime method ignore my timestamp or date input? &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What do I have to change to get this working?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for helping me out &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thilo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 12:59:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823113#M1049</guid>
      <dc:creator />
      <dc:date>2014-12-12T12:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert a timestamp into another timezone</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823114#M1050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume the reason is that ConvertToLocalTime couldn't interpret the input properly. Maybe you creates the same format like your manually example or you wrapped your timestamp#() into a timestamp().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 16:51:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823114#M1050</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2014-12-12T16:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert a timestamp into another timezone</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823115#M1051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can I see if the ConvertToLocalTime method could not parse the input? Is there any logfile I can have a look at? or something I could see in debug mode? For me it is like a blackbox with to less information on error behavior.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This extends to timestamp#, I assume that if the table preview show a value there the method was successful. And the documentation of ConvertToLocalTime expects a "timestamp" as first argument, so this should be fine, isn't it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I'll try the timestamp(timestamp#( ...) ) approach, although it looks like wasting resources and bad coding style &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 13:20:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823115#M1051</guid>
      <dc:creator />
      <dc:date>2014-12-15T13:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert a timestamp into another timezone</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823116#M1052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suggest you tried it first in a qv textbox with one or two original values manually and if this worked it should work in script, too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 13:33:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823116#M1052</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2014-12-15T13:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert a timestamp into another timezone</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823117#M1053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tackled the problem. It was a wrong date format...&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/blush.png" /&gt;&lt;/P&gt;&lt;P&gt;When using the correct date format, everything works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now it only depends on your flavor, if you want to use a date a timestamp, wrap the parsing call into a formattings call or use even time formating&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD *&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,ConvertToLocalTime(Timestamp#("Date" &amp;amp; ' ' &amp;amp; "Time", '$(DateFormat) hh:mm'), 'UTC-10:00') AS "Shifted Timestamp"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,ConvertToLocalTime(Date#&amp;nbsp;&amp;nbsp;&amp;nbsp; ("Date" &amp;amp; ' ' &amp;amp; "Time", '$(DateFormat) hh:mm'), 'UTC-10:00') AS "Shifted Date"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,ConvertToLocalTime(Timestamp(Timestamp#("Date" &amp;amp; ' ' &amp;amp; "Time", '$(DateFormat) hh:mm')), 'UTC-10:00') AS "Shifted Timestamp from Timestamp"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,ConvertToLocalTime(Date&amp;nbsp;&amp;nbsp;&amp;nbsp; (Date#&amp;nbsp;&amp;nbsp;&amp;nbsp; ("Date" &amp;amp; ' ' &amp;amp; "Time", '$(DateFormat) hh:mm'), 'YYYY-MM-DD hh:mm:ss'), 'UTC-10:00') AS "Shifted Date from Date"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,ConvertToLocalTime(Date&amp;nbsp;&amp;nbsp;&amp;nbsp; (Date#&amp;nbsp;&amp;nbsp;&amp;nbsp; ("Date" &amp;amp; ' ' &amp;amp; "Time", '$(DateFormat) hh:mm')), 'UTC-10:00') AS "Shifted Date from def Date"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,ConvertToLocalTime(Time(Timestamp#("Date" &amp;amp; ' ' &amp;amp; "Time", '$(DateFormat) hh:mm')), 'UTC-10:00') AS "Shifted Time from Timestamp"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,ConvertToLocalTime(Time(Date#&amp;nbsp;&amp;nbsp;&amp;nbsp; ("Date" &amp;amp; ' ' &amp;amp; "Time", '$(DateFormat) hh:mm'), 'YYYY-MM-DD hh:mm'), 'UTC-10:00') AS "Shifted Time from Date"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM '$(QvdConnection)/someQvdFile.qvd' (qvd)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE "Application ID"='$(ApplicationId)';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;They all return the same value, that the reason why I will use &lt;SPAN style="font-family: courier new,courier;"&gt; ,ConvertToLocalTime(Timestamp#("Date" &amp;amp; ' ' &amp;amp; "Time", '$(DateFormat) hh:mm'), 'UTC-10:00') AS "Shifted Timestamp"&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; because it is simple and does the trick.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 17:01:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/How-can-I-convert-a-timestamp-into-another-timezone/m-p/823117#M1053</guid>
      <dc:creator />
      <dc:date>2014-12-15T17:01:42Z</dc:date>
    </item>
  </channel>
</rss>

