|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
DateDiff, Query,
I'm trying to find out who in my Database is over 18 from the current date.
I have two tables in Access:- Household and Resident I have formatted both dates, age1 and ShortGB to dd/mm/yyyy, I keep getting a Data type mismatch error, Is there a way round my problem? I've been looking for two days now! ![]() <% MyDate = Date() Locale = SetLocale(2057) ShortGB = FormatDateTime(MyDate, 2) set RS1 = dbConn.Execute("Select DOB as age from Resident") do until RS1.EOF age1 = RS1("age") Set RS2 = dbConn.Execute( "Select Name, Address, PostCode from resident, Household where DateDiff('YYYY', 'age1' , '"&ShortGB&"') >18 and resident.Household_ID = Household.Household_ID" ) Name =RS1("Name") addy =RS1("Address") PC =RS1("PostCode") Response.write(Name) Response.Write(addy) Response.Write(PC) Loop %> Thanks for your time! Dan, |
|
#2
|
|||
|
|||
|
Sorry....
Sorry, i forgot to say.
Its the RS2 Query that i'm having problems with! DateDiff('YYYY', DateOfBirth, CurrentDate) is my syntax correct? Thanks ![]() Dan, |
|
#3
|
|||
|
|||
|
I'm in ahurry to get my lunch but would this help?
targetDate = cdate(month(DateAdd("YYYY", -18, Now)) & "/" & day(DateAdd("YYYY", -18, Now)) & "/" & year(DateAdd("YYYY", -18, Now)) ) then in the SQL do something like this: SELECT * FROM tblUsers WHERE DOB>=#" & targetDate & "#
__________________
"We teach people to learn, we never teach them how to grow" - Oscar Wilde |
|
#4
|
|||
|
|||
thankyou so much for your help!it works perfectly DanDan says cheers too. you dont know how long we have been trying to get that right for! Thankyou again ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > DateDiff, Query, |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|