# How use function GotoIfTime()

Hi, In our company we work for 8:00AM to 6:00PM, how can i redirect all incoming calls to SIP/205 when we are closed (6:00PM)
?? If we are open (8:00AM to 5.59) redirect calls to SIP/201

``````exten => _X.,1,Noop(DDI CALL FROM \${EXTEN})
exten => _X.,n,GotoIfTime(08:00-17:59|mon-fri|*|*?open)
exten => _X.,n(closed),Dial(SIP/205)
exten => _X.,n(closed),Hangup()
exten => _X.,n(open),Dial(SIP/201)
exten => _X.,n(open),Hangup()``````

Or similar, but you get the idea

No, it doesn’t work
i have this

exten=>s,1,Noop(DDI CALL FROM \${EXTEN})
exten=>s,n,GotoIfTime(08:00-17:59|mon-fri||?open)
exten=>s,n(closed),Dial(SIP/205)
exten=>s,n(closed),Hangup()
exten=>s,n(open),Dial(SIP/201)
exten=>s,n(open),Hangup()

And at everytime the SIP/205 ring, the SIP/201 do not ring when we are close, i test it using this

exten=>s,1,Noop(DDI CALL FROM \${EXTEN})
exten=>s,n,GotoIfTime(17:00-17:59|mon-fri||?open)
exten=>s,n(closed),Dial(SIP/205)
exten=>s,n(closed),Hangup()
exten=>s,n(open),Dial(SIP/201)
exten=>s,n(open),Hangup()

And my PBX still ringing 205. Im using asterisk 1-4-21.1

Hi

Take it from me that’s a working example taken directly from a working system

check your system time and post the cli output of a call.

Ian

Sorry to pull this post up from ages ago!

Could anyone let me know how to change the actual message? I have the below set up were mainmenu-hol is the ‘Christmas message’ so can change the dates/ times, etc but I’m not sure where the message is saved or how to change the message. The mainmenu-day is just the out of hours message.

Hopefully this is just a simple change - as I’ve mentioned in other posts I’ve taken this on from an existing set up and just working things out as I go!

exten => s,4,GotoIfTime(8:00-17:00|mon-fri|