Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
micky--4444
Starting Member
19 Posts |
Posted - 2010-06-07 : 07:43:54
|
| I have constructed a test SQL Query. I run it through query analyser and it appears to work for the code below.SELECT Users.*, aspnet_Membership.Email FROM Users INNER JOINaspnet_Membership ON Users.UserID=aspnet_Membership.UserID WHEREDateofBirth < DateAdd(yy,-17,getDate())AND DateofBirth > DateAdd(yy,-24,getDate())The problem is that for one of the test dates I'm using to see if it works, the date is 1987-05-03 00:00:00.000I don't understand how 1987-05-03 00:00:00.000 is less than DateAdd(yy,-17,getDate()), surely it should be greater than, as the date comes before. Shouldn't it? or am I missing something.thanks. |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-06-07 : 07:52:46
|
| Current year is 2010.17 year less is 1993.. and 1987 is less than 1993... Isn't ?I am here to learn from Masters and help new bees in learning. |
 |
|
|
micky--4444
Starting Member
19 Posts |
Posted - 2010-06-08 : 04:06:33
|
| 1987 is less than 1993... Isn't ?Is it, I would have thought that a date of 1987 was greater than 1993, or maybe it's just treated as a number? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-08 : 05:01:44
|
quote: Originally posted by micky--4444 1987 is less than 1993... Isn't ?Is it, I would have thought that a date of 1987 was greater than 1993, or maybe it's just treated as a number?
Now, did you get correct result?MadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-08 : 05:06:42
|
Your own querySELECT DateAdd(yy,-24,getDate()), DateAdd(yy,-17,getDate()) returns the following dates1986-06-08 1993-06-08 I am pretty sure a date with year 1987 falls inbetween those two dates. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|
|
|
|