cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

License delivery maintenance is planned for Saturday, July 26, between 12:00 and 20:00 CEST. During this time, you may experience outages or limited availability across our services, including BIMcloud SaaS, License Delivery, Graphisoft ID (for customer and company management), Graphisoft Store, and BIMx Web Viewer. More details…

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Problem using DATETIME in IF statement

jakubc7
Advocate
I'm trying to write a code that will PRINT a message if it's a certain time or day.
I managed to REQUEST the time and day ... call it out using TEXT2, however I cannot use it in IF THEN ENDIF statement.

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.

Any help appreciated. Thanks.

MASTER CODE
!---Time and Day Limits---
hour=0
day=0

a = REQUEST("DateTime","%H",hour)
b = REQUEST("DateTime","%w",day)

IF day = 13 THEN
PRINT "It's lunch time."
ENDIF
ArchiCAD 10 - 25 | Windows 10
ARCHIcreate | Perth, Western Australia
archicad solutions | content creation | training | software implementation
2 REPLIES 2
Barry Kelly
Moderator
The returned hour and day variables are actually text variables (even though you initialised them as numbers).
You will need to convert them to numbers.
Try...

n=SPLIT(hour ,"%n",hour_num)

n=SPLIT(day ,"%n",day_num)



To prove it if you were to type ... PRINT hour + hour
you would get 1313 (if it was 1.00pm)

but ... PRINT hour_num + hour_num
you will get 26

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
jakubc7
Advocate
Thanks again Barry.
I was reading that the date and time are not actual numbers but couldn't find a way to convert it.

Thank you!
ArchiCAD 10 - 25 | Windows 10
ARCHIcreate | Perth, Western Australia
archicad solutions | content creation | training | software implementation