<?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 Check if a timestamp variable is between 2 timestamp variables. in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199615#M58477</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, I missed that the first time. Your variable expressions are only changing the FORMAT of the timestamps. They are NOT changing the underlying values. You need to actually modify the values themselves, and the format is completely irrelevant for your comparison, which will be done numerically. So:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LET vNow = now();&lt;BR /&gt;LET vStartTime = monthstart(today())+5/24;&lt;BR /&gt;LET vEndTime = monthstart(today())+5.25/24;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;IF vNow &amp;gt;= vStartTime and vNow &amp;lt;= vEndTime THEN&lt;BR /&gt; SET vFirstRun = 1;&lt;BR /&gt;ELSE&lt;BR /&gt; SET vFirstRun = 0;&lt;BR /&gt;END IF;&lt;/P&gt;&lt;P&gt;And to test a matching condition:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LET vNow = monthstart(today())+5.1/24;&lt;/P&gt;&lt;P&gt;And to test a non-matching condition:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LET vNow = monthstart(today())+4/24;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Sep 2010 01:05:18 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2010-09-14T01:05:18Z</dc:date>
    <item>
      <title>Check if a timestamp variable is between 2 timestamp variables.</title>
      <link>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199612#M58474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In this scenario, I need to check if the execution time is between 5:00AM-5:15AM every first day of each month. I'm having trouble with the timestamp format and it is giving me script error during execution. Can you help me find out what is wrong ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;LET vNow= timestamp(Now(),'M/D/YYYY h:mm:ss TT') ;&lt;BR /&gt;LET vStartTime = timestamp(monthstart(Today()),'M/D/YYYY 5:00:00 TT');&lt;BR /&gt;LET vEndTime = timestamp(monthstart(Today()),'M/D/YYYY 5:15:00 TT');&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;IF $(vNow) &amp;gt;= $(vStartTime) and&lt;BR /&gt; $(vNow) &amp;lt;= $(vEndTime) THEN&lt;BR /&gt; SET vFirstRun = 1;&lt;BR /&gt;ELSE&lt;BR /&gt; SET vFirstRun = 0;&lt;BR /&gt;END IF;&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Sep 2010 00:17:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199612#M58474</guid>
      <dc:creator />
      <dc:date>2010-09-14T00:17:44Z</dc:date>
    </item>
    <item>
      <title>Check if a timestamp variable is between 2 timestamp variables.</title>
      <link>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199613#M58475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The $() is doing dollar sign expansion, which is to say it's directly inserting the dates and times into your script. All you want to do is compare the variables themselves. Also, the IF and THEN need to be on the same line, I believe. So this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LET vNow= timestamp(Now(),'M/D/YYYY h:mm:ss TT') ;&lt;BR /&gt;LET vStartTime = timestamp(monthstart(Today()),'M/D/YYYY 5:00:00 TT');&lt;BR /&gt;LET vEndTime = timestamp(monthstart(Today()),'M/D/YYYY 5:15:00 TT');&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;IF vNow &amp;gt;= vStartTime and vNow &amp;lt;= vEndTime THEN&lt;BR /&gt; SET vFirstRun = 1;&lt;BR /&gt;ELSE&lt;BR /&gt; SET vFirstRun = 0;&lt;BR /&gt;END IF;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Sep 2010 00:37:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199613#M58475</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-09-14T00:37:47Z</dc:date>
    </item>
    <item>
      <title>Check if a timestamp variable is between 2 timestamp variables.</title>
      <link>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199614#M58476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;I changed my logic as per suggestion and didn't get any errors. Great !&lt;/P&gt;&lt;P&gt;I tested simply by updating the vNow as timestamp(monthstart(Today()),'M/D/YYYY 4:00:00 TT').&lt;/P&gt;&lt;P&gt;Since 4:00AM is not between 5 and 5:15 AM, I should get back a result of vFirstRun = 0. However, I got vFirstRun = 1 instead.&lt;/P&gt;&lt;P&gt;It looks like the "and" doesn't work and just checks if either of the expression satisfies.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Sep 2010 00:47:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199614#M58476</guid>
      <dc:creator />
      <dc:date>2010-09-14T00:47:36Z</dc:date>
    </item>
    <item>
      <title>Check if a timestamp variable is between 2 timestamp variables.</title>
      <link>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199615#M58477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, I missed that the first time. Your variable expressions are only changing the FORMAT of the timestamps. They are NOT changing the underlying values. You need to actually modify the values themselves, and the format is completely irrelevant for your comparison, which will be done numerically. So:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LET vNow = now();&lt;BR /&gt;LET vStartTime = monthstart(today())+5/24;&lt;BR /&gt;LET vEndTime = monthstart(today())+5.25/24;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;IF vNow &amp;gt;= vStartTime and vNow &amp;lt;= vEndTime THEN&lt;BR /&gt; SET vFirstRun = 1;&lt;BR /&gt;ELSE&lt;BR /&gt; SET vFirstRun = 0;&lt;BR /&gt;END IF;&lt;/P&gt;&lt;P&gt;And to test a matching condition:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LET vNow = monthstart(today())+5.1/24;&lt;/P&gt;&lt;P&gt;And to test a non-matching condition:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LET vNow = monthstart(today())+4/24;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Sep 2010 01:05:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199615#M58477</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-09-14T01:05:18Z</dc:date>
    </item>
    <item>
      <title>Check if a timestamp variable is between 2 timestamp variables.</title>
      <link>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199616#M58478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks John. It worked beautifully !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Sep 2010 01:26:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-if-a-timestamp-variable-is-between-2-timestamp-variables/m-p/199616#M58478</guid>
      <dc:creator />
      <dc:date>2010-09-14T01:26:42Z</dc:date>
    </item>
  </channel>
</rss>

