#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    24
    Rep Power
    0

    Scheduled task exclusion


    Greetings members,
    I am new to the forum and have searched briefly but couldn't find exactly what i was after, so forgive me if this has been asked before.

    My question is a simple one , I hope. I have a scheduled task that sends an email on the every hour within 9 am til 5 pm. However, I wish to exclude both Saturday and Sunday from this task. So far, this is what I have, but it is not working. I've used DayofWeek, but I also tried with DayOfWeekAsString, alas, with the same results.


    -------------------------------------
    <cfset TodaysDate = Now()>

    <CFIF DayOfWeek(TodaysDate) NEQ 6 OR DayOfWeek(TodaysDate) NEQ 7>

    <cfmail from="server@esi.co.nz"
    to="markh@cwc.co.nz;"
    subject="CWC STAFF BREAK">
    Wake up!
    </cfmail>

    <cfelse>
    <cfabort>

    </CFIF>

    ----------------------------------------

    Any ideas? All help appreciated.

    Mark

    Comments on this post

    • Gran Roguismo agrees
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    The problem is that the dayOfWeek() for Saturday is 7 and the dayOfWeek() for Sunday is 1:

    Prints 7: #dayofweek( '7/12/03' )#
    Prints 1: #dayofweek( '7/13/03' )#

    So you really want:

    <CFIF DayOfWeek( Now() ) NEQ 7 OR DayOfWeek( Now() ) NEQ 1>

    Hope that helps.

    Brian
  4. #3
  5. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    Actually you can tighten it up a little like this:

    <cfif not listFind( '1,7', dayOfWeek( now() ) )>

IMN logo majestic logo threadwatch logo seochat tools logo