Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More than just the usual problems with Dates in queries

Status
Not open for further replies.

LittleSmudge

Programmer
Mar 18, 2002
2,848
GB
I have the following clause in a A2k query

WHERE DateAdd("yyyy",18,[DoB]) > (DateAdd("d",1,'30/08/' & Year([EnrolmentDate])))

This works but the DateAdd("d",1,{date}) bit is messy !

What it is doing is

If Learner's DateOfBirth + 18 years ( Their 18th birthday )
is AFTER
the 31st August on the Year of their Course Enrolment
THEN Show Record
ELSE Omit

( Enrolments take place at anytime throughout the year )

If I simply use
('31/08/' & Year([EnrolmentDate]))
It fails to work properly

I'm, in effect, using the DateAdd function to do a type conversion. However, I can't find a way of formatting
'31/August/' & Year([EnrolmentDate]) into a Date without it.

Any ideas - or am I stuck using this fudge ?





G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
WHERE DateAdd("yyyy",18,[DoB]) > DateSerial(Year([EnrolmentDate]),8,31)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 

DateSerial(YearsAsInteger, MonthsAsInteger, DaysAsInteger)

JUST what I needed PHV thanks (again).





G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top