On 11/29/12 2:23 PM, Andrew Kluthe wrote:
That's what I'm looking for! Great.

However, I tried what I think I am supposed to do in the script below
and my dates are about three days off.

This function is supposed to give me the date for monday of the week
where the date paramater is.

If the paramater is empty it uses todays date.

function DetermineWeek pDate
    if pDate is empty then
       put the date into sDate
    else
       put pDate into sDate
    end if
    convert sDate to dateItems
    answer sDate
    set the itemDelimiter to ","
    put item -1 of sDate into sDay
    switch sDay
       case "2" --Monday
          put 0 into sDiff
       case "3" --Tuesday
          put 1 into sDiff
       case "4" --Wednesday
          put 2 into sDiff
       case "5" --Thursday
          put 3 into sDiff
       case "6" --Friday
          put 4 into sDiff
       case "7" --Saturday
          put 5 into sDiff
       case "1" --Sunday
          put 6 into sDiff
    end switch
    put item 3 of sDate into sDayOfMonth
    put sDayOfMonth - sDiff into sNewDay
    put sNewDay into item 3 of sDate
    answer sDate
    convert sDate to date
    return sDate
end DetermineWeek

For instance leaving the paramater blank should provide me today
(11/29/12) with a date of 11/26/12 but instead I am returned 11/23/12.

You forgot the "break" statements in the switch. Everything will fall through to a difference of 6.

--
Jacqueline Landman Gay         |     [email protected]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to