<?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 Problem using DATETIME in IF statement in Libraries &amp; objects</title>
    <link>https://community.graphisoft.com/t5/Libraries-objects/Problem-using-DATETIME-in-IF-statement/m-p/190072#M12055</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;T&gt;I'm trying to write a code that will PRINT a message if it's a certain time or day.&lt;BR /&gt;
I managed to REQUEST the time and day ... call it out using TEXT2, however I cannot use it in IF THEN ENDIF statement.&lt;BR /&gt;
&lt;BR /&gt;
The code doesn't come up with errors until I try to save (error in 2d script ... even though 2d is empty). I'm sure I'm missing something minor.&lt;BR /&gt;
&lt;BR /&gt;
Any help appreciated. Thanks.&lt;BR /&gt;
&lt;BR /&gt;
MASTER CODE&lt;BR /&gt;
!---Time and Day Limits---&lt;BR /&gt;
hour=0&lt;BR /&gt;
day=0&lt;BR /&gt;
&lt;BR /&gt;
a = REQUEST("DateTime","%H",hour)&lt;BR /&gt;
b = REQUEST("DateTime","%w",day)&lt;BR /&gt;
&lt;BR /&gt;
IF day = 13 THEN&lt;BR /&gt;
PRINT "It's lunch time."&lt;BR /&gt;
ENDIF&lt;/T&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 18 Jul 2014 05:00:08 GMT</pubDate>
    <dc:creator>jakubc7</dc:creator>
    <dc:date>2014-07-18T05:00:08Z</dc:date>
    <item>
      <title>Problem using DATETIME in IF statement</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Problem-using-DATETIME-in-IF-statement/m-p/190072#M12055</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;T&gt;I'm trying to write a code that will PRINT a message if it's a certain time or day.&lt;BR /&gt;
I managed to REQUEST the time and day ... call it out using TEXT2, however I cannot use it in IF THEN ENDIF statement.&lt;BR /&gt;
&lt;BR /&gt;
The code doesn't come up with errors until I try to save (error in 2d script ... even though 2d is empty). I'm sure I'm missing something minor.&lt;BR /&gt;
&lt;BR /&gt;
Any help appreciated. Thanks.&lt;BR /&gt;
&lt;BR /&gt;
MASTER CODE&lt;BR /&gt;
!---Time and Day Limits---&lt;BR /&gt;
hour=0&lt;BR /&gt;
day=0&lt;BR /&gt;
&lt;BR /&gt;
a = REQUEST("DateTime","%H",hour)&lt;BR /&gt;
b = REQUEST("DateTime","%w",day)&lt;BR /&gt;
&lt;BR /&gt;
IF day = 13 THEN&lt;BR /&gt;
PRINT "It's lunch time."&lt;BR /&gt;
ENDIF&lt;/T&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 18 Jul 2014 05:00:08 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Problem-using-DATETIME-in-IF-statement/m-p/190072#M12055</guid>
      <dc:creator>jakubc7</dc:creator>
      <dc:date>2014-07-18T05:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using DATETIME in IF statement</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Problem-using-DATETIME-in-IF-statement/m-p/190073#M12056</link>
      <description>The returned hour and day variables are actually text variables (even though you initialised them as numbers).&lt;BR /&gt;
You will need to convert them to numbers.&lt;BR /&gt;
Try...&lt;BR /&gt;
&lt;BR /&gt;
n=SPLIT(hour ,"%n",hour_num)&lt;BR /&gt;
&lt;BR /&gt;
n=SPLIT(day ,"%n",day_num)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
To prove it if you were to type ... PRINT hour + hour&lt;BR /&gt;
you would get 1313 (if it was 1.00pm)&lt;BR /&gt;
&lt;BR /&gt;
but ... PRINT hour_num + hour_num&lt;BR /&gt;
you will get 26&lt;BR /&gt;
&lt;BR /&gt;
Barry.</description>
      <pubDate>Fri, 18 Jul 2014 06:05:06 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Problem-using-DATETIME-in-IF-statement/m-p/190073#M12056</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2014-07-18T06:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using DATETIME in IF statement</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Problem-using-DATETIME-in-IF-statement/m-p/190074#M12057</link>
      <description>Thanks again Barry.&lt;BR /&gt;
I was reading that the date and time are not actual numbers but couldn't find a way to convert it.&lt;BR /&gt;
&lt;BR /&gt;
Thank you!</description>
      <pubDate>Fri, 18 Jul 2014 07:00:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Problem-using-DATETIME-in-IF-statement/m-p/190074#M12057</guid>
      <dc:creator>jakubc7</dc:creator>
      <dc:date>2014-07-18T07:00:48Z</dc:date>
    </item>
  </channel>
</rss>

