Access 97 Date format problem
Morning All,
âI have an application where I need to show courses attended for a member for the memberâs current training year. So if a member has a training year of 1st November 2003 to 31st October 2004, the app has to show the courses attended during that year.
âEach member has a record showing the month and day his training year starts
âI have assigned variables TrMth and TrDay for those integers.
âTo obtain the start date for the memberâs training year, I use the following (courtesy Greg Serrano) by âinitialising the variable dtmStartdate:
dtmStartDate = DateSerial(Year(Date), TrMth, TrDay)
âthen to obtain the end date, I use;
dtmEndDate = DateAdd("yyyy", 1, dtmStartDate - 1)
'I then use a routine to re initialise if appropriate, namely where the date the search is carried out is after â31st December in any one year
If dtmStartDate > Date Then
dtmStartDate = DateSerial(Year(Date) - 1, TrMth, TrDay)
dtmEndDate = DateAdd("yyyy", 1, dtmStartDate - 1)
End If
âThis is to ensure that the search always shows the correct year â otherwise a search in early 2004 would show a memberâs course starting ist November 2004.
âThe variables are then incorporated into a query to find all the courses between dtmStartdate and dtmEnddate, and the routine works well, save for one problem, which is that dtmStartDate is wrongly formatted. If I run the routine for a member who has not attended any courses for his training year (1st November 2003 to 31st October 2004) the query shows he has attended courses, but is bringing them in from earlier dates. When I examine the query image the following appears in the Course date field:
â Between #11/01/2003# And #31/10/2004#
âinstead of
âBetween #01/11/2003# And #31/10/2004#
âCuriously, the end date is formatted correctly.
âI imagine this is a formatting problem â any ideas?
|