[AccessD] Forcing a date calculation

Stuart McLachlan stuart at lexacorp.com.pg
Wed Aug 31 17:43:06 CDT 2005


On 31 Aug 2005 at 23:00, Chris Swann wrote:

> All,
> 
> I have a form that users are supposed to enter a start date, always a Monday
> and an end date, always the Sunday after.
> 
> However, they seem completely unable to enter these dates correctly so I am
> trying to see if there is a way to force a date into the system using Date()
> and then going back to the previous Sunday and then working out the Monday
> prior to that.
> 
> So, 31 August 2005 would go back to Sunday 28th August 2005 and I would then
> subtract days to get Monday 22 August 2005.
> 
> Could anybody give me a pointer on if this is possible as the data being
> returned currently is normally incorrect and this is causing more than a few
> headaches !!
> 

This will givew you the current date for any Sunday and the previous Sunday 
for any day other than Sunday:

Function PreviousSunday(CurrDate As Date) As Date
    PreviousSunday = CurrDate - Weekday(CurrDate) + 1
End Function

PrevisouSunday() - 6 will give you the preceding Monday.

-- 
Stuart





More information about the AccessD mailing list