Script that will only run if it falls between a weekday/time range

I need an Applescript that will only run if it falls between a weekday/time range:

If weekday is greater than Thursday at 4pm and less than Friday at 8pm then
do something here
else
end if

I’m failing miserably at my attempt. Can anyone get me started? Thanks

Hi,

try this


set {weekday:wkd, hours:hr} to current date

if (wkd is Thursday and hr ≥ 16) or (wkd is Friday and hr < 20) then
	-- do something here
end if

Hello Rob,

greetings from Germany. I hope my answer is understandably :wink:

The solution is two nested if:

set t to current date
#set t to date "Donnerstag, 13. August 2015 04:01:00"# Test
if weekday of t is in {Thursday, Friday} then # right day
	if hours of t is greater than or equal to 4 and hours of t is less than 8 then # right time
		my dowhattodohandler()
	end if
end if

It es easier to handle than a very long if-statement.

Thanks for both replies!

pm ist nach zwölf :wink: (pm is after noon)

PS:

@Macmissionar, unfortunately your handler doesn’t work because it’s considering the range from 4 to 8 of both days instead of 4 Thursday - 8 Friday