<?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 to use XQL parse_timestamp in Cortex XDR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/how-to-use-xql-parse-timestamp/m-p/554333#M4993</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/307702"&gt;@unlucky&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reaching out on LiveCommunity!&lt;/P&gt;
&lt;P&gt;I think the function you are looking for is format_timestamp in place of format_string because your data is already in timestamp format.&lt;/P&gt;
&lt;P&gt;Lets understand the definition of these 3 functions.&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hljs-built_in"&gt;parse_timestamp&lt;/SPAN&gt;&lt;SPAN&gt;() -&amp;gt;&amp;nbsp;The&amp;nbsp;&lt;CODE class="computeroutput hljs language-scss"&gt;&lt;SPAN class="hljs-built_in"&gt;parse_timestamp&lt;/SPAN&gt;()&lt;/CODE&gt;&amp;nbsp;function returns a TIMESTAMP object after converting a string representation of a timestamp.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="hljs-built_in"&gt;format_timestamp&lt;/SPAN&gt;() -&amp;gt;&amp;nbsp;The&amp;nbsp;&lt;CODE class="computeroutput hljs language-scss"&gt;&lt;SPAN class="hljs-built_in"&gt;format_timestamp&lt;/SPAN&gt;()&lt;/CODE&gt;&amp;nbsp;function returns a string after formatting a timestamp according to a specified string format.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="hljs-built_in"&gt;&lt;SPAN class="proto-highlight"&gt;format_string&lt;/SPAN&gt;&lt;/SPAN&gt;() -&amp;gt;&amp;nbsp;The&amp;nbsp;&lt;CODE class="computeroutput hljs language-scss"&gt;&lt;SPAN class="hljs-built_in"&gt;&lt;SPAN class="proto-highlight"&gt;format_string&lt;/SPAN&gt;&lt;/SPAN&gt;()&lt;/CODE&gt;&amp;nbsp;function returns a string from a format string that contains zero or more format specifiers, along with a variable length list of additional arguments that matches the format specifiers.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Since the string you are trying to convert is already a timestamp hence please use format_timestamp function which will take a timestamp and return a string to parse_timestamp function to convert it to a timestamp of your choice. I have tried below line and its working for me.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;alter time_test = parse_timestamp("%Y/%m/%d %H:%M:%S", format_timestamp("%Y/%m/%d %H:%M:%S", _time))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Below are the reference link for above functions.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/parse_timestamp" target="_blank"&gt;https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/parse_timestamp&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/format_timestamp" target="_blank"&gt;https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/format_timestamp&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/format_string" target="_blank"&gt;https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/format_string&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Aug 2023 16:22:32 GMT</pubDate>
    <dc:creator>nsinghvirk</dc:creator>
    <dc:date>2023-08-18T16:22:32Z</dc:date>
    <item>
      <title>How to use XQL parse_timestamp</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/how-to-use-xql-parse-timestamp/m-p/554191#M4990</link>
      <description>&lt;P&gt;I am trying to &lt;STRONG&gt;convert a string to a timestamp object&lt;/STRONG&gt; and cannot understand how the parse_timestamp function works.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;My string is as follow :&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;EM&gt;"2023-08-17T17:40:38.000246+0300"&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;My XQL query is as follow :&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;alter&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;timestamp = parse_timestamp("%Y-%m-%dT%H:%M:%S", format_string("%s", &amp;lt;field containing the timestamp string&amp;gt;))&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;This is clearly not the right way to use this function, but I cannot find any clear example showing how the function works...&lt;BR /&gt;&lt;STRONG&gt;Does anybody have a working example and can show their input and output ?&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;The &lt;A href="https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/parse_timestamp" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;&amp;nbsp;is not helpful&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 17 Aug 2023 15:38:38 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/how-to-use-xql-parse-timestamp/m-p/554191#M4990</guid>
      <dc:creator>unlucky</dc:creator>
      <dc:date>2023-08-17T15:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use XQL parse_timestamp</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/how-to-use-xql-parse-timestamp/m-p/554333#M4993</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/307702"&gt;@unlucky&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reaching out on LiveCommunity!&lt;/P&gt;
&lt;P&gt;I think the function you are looking for is format_timestamp in place of format_string because your data is already in timestamp format.&lt;/P&gt;
&lt;P&gt;Lets understand the definition of these 3 functions.&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hljs-built_in"&gt;parse_timestamp&lt;/SPAN&gt;&lt;SPAN&gt;() -&amp;gt;&amp;nbsp;The&amp;nbsp;&lt;CODE class="computeroutput hljs language-scss"&gt;&lt;SPAN class="hljs-built_in"&gt;parse_timestamp&lt;/SPAN&gt;()&lt;/CODE&gt;&amp;nbsp;function returns a TIMESTAMP object after converting a string representation of a timestamp.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="hljs-built_in"&gt;format_timestamp&lt;/SPAN&gt;() -&amp;gt;&amp;nbsp;The&amp;nbsp;&lt;CODE class="computeroutput hljs language-scss"&gt;&lt;SPAN class="hljs-built_in"&gt;format_timestamp&lt;/SPAN&gt;()&lt;/CODE&gt;&amp;nbsp;function returns a string after formatting a timestamp according to a specified string format.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="hljs-built_in"&gt;&lt;SPAN class="proto-highlight"&gt;format_string&lt;/SPAN&gt;&lt;/SPAN&gt;() -&amp;gt;&amp;nbsp;The&amp;nbsp;&lt;CODE class="computeroutput hljs language-scss"&gt;&lt;SPAN class="hljs-built_in"&gt;&lt;SPAN class="proto-highlight"&gt;format_string&lt;/SPAN&gt;&lt;/SPAN&gt;()&lt;/CODE&gt;&amp;nbsp;function returns a string from a format string that contains zero or more format specifiers, along with a variable length list of additional arguments that matches the format specifiers.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Since the string you are trying to convert is already a timestamp hence please use format_timestamp function which will take a timestamp and return a string to parse_timestamp function to convert it to a timestamp of your choice. I have tried below line and its working for me.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;alter time_test = parse_timestamp("%Y/%m/%d %H:%M:%S", format_timestamp("%Y/%m/%d %H:%M:%S", _time))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Below are the reference link for above functions.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/parse_timestamp" target="_blank"&gt;https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/parse_timestamp&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/format_timestamp" target="_blank"&gt;https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/format_timestamp&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/format_string" target="_blank"&gt;https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/format_string&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 16:22:32 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/how-to-use-xql-parse-timestamp/m-p/554333#M4993</guid>
      <dc:creator>nsinghvirk</dc:creator>
      <dc:date>2023-08-18T16:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to use XQL parse_timestamp</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/how-to-use-xql-parse-timestamp/m-p/554337#M4994</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;SPAN class="xql-error-title"&gt;Error&lt;/SPAN&gt;&lt;SPAN class="xql-error-details" title="Field timestamp for function format_timestamp is invalid. Expected date but received string."&gt;Field timestamp for function format_timestamp is invalid. Expected date but received string.&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="xql-error-details" title="Field timestamp for function format_timestamp is invalid. Expected date but received string."&gt;As I was saying, even though my string contains a timestamp, it is still a string!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="xql-error-details" title="Field timestamp for function format_timestamp is invalid. Expected date but received string."&gt;Maybe there is something I am not understanding here, but what I am trying to achieve is to convert this string to a date type.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 17:15:39 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/how-to-use-xql-parse-timestamp/m-p/554337#M4994</guid>
      <dc:creator>unlucky</dc:creator>
      <dc:date>2023-08-18T17:15:39Z</dc:date>
    </item>
  </channel>
</rss>

