Paul
|
| Posted: 05/08/2002, 9:22 AM |
|
I would like to add validation that first of all finds the current week commencing date, based on Monday as the first day of the week. So for example for today (08/05/2002) i need it to return the value 'CurrentWeek' 06/05/2002
And then i need to compare 'CurrentWeek' to another value 'Week_Commencing' and if the difference is greater than 13 days then it should error?
The big challenge for me is finding the weekcommencing date for the current week... any ideas?
|
|
|
 |
Ken Hardwick
|
| Posted: 05/08/2002, 11:19 AM |
|
Paul,
You didn't indicate your programming language but here is one using ASP.
I designed it such that if it is a Sunday it goes back to the previous
Monday...You can change code to add one day instead of subtracting 6
if you want the next day (a monday)
<%
for cnt = 0 to 31
TheDate = Date + Cnt
DayOfWeek = DatePart("w",TheDate)
response.write FormatDateTime(thedate, vbLongDate) & "<br>"
response.write dayofweek & "<br>"
if DayofWeek = 1 then
MondayDate = theDate - 6
else
Mondaydate = Thedate - (dayofweek-2)
End if
response.write MondayDate & "<br>-------------------------<br>"
next
%>
|
|
|
 |
Paul
|
| Posted: 05/09/2002, 12:59 AM |
|
Ken you are a star :o) adapted it and it works a treat... this is the final code i used (lifted most of it from yours.... )
'-------------------------------
' Current MondayDate Format
'-------------------------------
TheDate = Date + Cnt
DayOfWeek = DatePart("w",TheDate)
if DayofWeek = 1 then
MondayDate = theDate - 6
else
Mondaydate = Thedate - (dayofweek-2)
End if
'-------------------------------
' Validate field
'-------------------------------
if fldweek_commencing > "" then
wkDate = fldweek_commencing
wkWeekDay = Weekday(wkDate)
if wkWeekDay <> 2 then
sHoliday_RequestErr = sHoliday_RequestErr & "The week commencing date is not a Monday<br>"
end if
If DateDiff("d",fldweek_commencing,MondayDate) > 7 then
sHoliday_RequestErr = sHoliday_RequestErr & "Holidays cannot be back-dated by more than one week<br>"
end if
end if
|
|
|
 |
Ken Hardwick
|
| Posted: 05/09/2002, 3:33 AM |
|
Hi Paul,
The time I take (and others) take to provide help/suggestions to others in
this forum is a valuable "limited" resourse, so it is extremely nice
to get feedback (especially positive) from those whom I (we) attempt to help.
So, thanks for your feedback...ken
|
|
|
 |
|