;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfGetMondayOfWeek (strYmdHms) Return TimeAdd (TimeSubtract (strYmdHms, "0:0:" : (TimeJulianDay (strYmdHms) + 5) mod 7), "0:0:1") ; The function returns a datetime string of the calculated day, leaves Hms untouched. #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfGetTuesdayOfWeek (strYmdHms) Return TimeAdd (TimeSubtract (strYmdHms, "0:0:" : (TimeJulianDay (strYmdHms) + 5) mod 7), "0:0:2") ; The function returns a datetime string of the calculated day, leaves Hms untouched. #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfGetWednesdayOfWeek (strYmdHms) Return TimeAdd (TimeSubtract (strYmdHms, "0:0:" : (TimeJulianDay (strYmdHms) + 5) mod 7), "0:0:3") ; The function returns a datetime string of the calculated day, leaves Hms untouched. #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfGetThursdayOfWeek (strYmdHms) Return TimeAdd (TimeSubtract (strYmdHms, "0:0:" : (TimeJulianDay (strYmdHms) + 5) mod 7), "0:0:4") ; The function returns a datetime string of the calculated day, leaves Hms untouched. #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfGetFridayOfWeek (strYmdHms) Return TimeAdd (TimeSubtract (strYmdHms, "0:0:" : (TimeJulianDay (strYmdHms) + 5) mod 7), "0:0:5") ; The function returns a datetime string of the calculated day, leaves Hms untouched. #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfGetSaturdayOfWeek (strYmdHms) Return TimeAdd (TimeSubtract (strYmdHms, "0:0:" : (TimeJulianDay (strYmdHms) + 5) mod 7), "0:0:6") ; The function returns a datetime string of the calculated day, leaves Hms untouched. #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfGetSundayOfWeek (strYmdHms, intMode) If !intMode Then Return TimeSubtract (strYmdHms, "0:0:" : (TimeJulianDay (strYmdHms) + 5) mod 7) Return TimeAdd (TimeSubtract (strYmdHms, "0:0:" : (TimeJulianDay (strYmdHms) + 5) mod 7), "0:0:7") ;.......................................................................................................................................... ; This user defined function "udfGetSundayOfWeek" determines the sunday of the week which contains the given date. ; intMode = 0 ... Sunday is the first day of the week (american usage). ; intMode = 1 ... Sunday is the last day of the week (ISO 8601). ; The function returns a datetime string of the calculated day, leaves Hms untouched. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. strToday = TimeYmdHms () ; e. g. "2009:07:27:08:10:23". strSunday0 = udfGetSundayOfWeek (strToday, 0) ; e. g. "2009:07:26:08:10:23". strMonday = udfGetMondayOfWeek (strToday) ; e. g. "2009:07:27:08:10:23". strTuesday = udfGetTuesdayOfWeek (strToday) ; e. g. "2009:07:28:08:10:23". strWednesday = udfGetWednesdayOfWeek (strToday) ; e. g. "2009:07:29:08:10:23". strThursday = udfGetThursdayOfWeek (strToday) ; e. g. "2009:07:30:08:10:23". strFriday = udfGetFridayOfWeek (strToday) ; e. g. "2009:07:31:08:10:23". strSaturday = udfGetSaturdayOfWeek (strToday) ; e. g. "2009:08:01:08:10:23". strSunday1 = udfGetSundayOfWeek (strToday, 1) ; e. g. "2009:08:02:08:10:23". Exit