Author |
Topic |
jdslim164
Starting Member
5 Posts |
Posted - 2006-09-04 : 18:03:34
|
I plant lettuce in fields multiple times during the season. when i plant a trial it gets a wet date, lets just say 10-20-06. i need to go back to each planting 14 days after its been planted. How do i write the statement to display these lettuce trials.i tried this statement SELECT species, trialnum, wetdateFROM mapdataWHERE (wetdate = DATEADD([Day], - 14, GETDATE()))Not sure what to try next.jdslim |
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2006-09-04 : 18:35:52
|
GETDATE() returns the time of the day as well.Try;WHERE DATEDIFF(DAY,wetdate,GETDATE())=14rockmoose |
|
|
jdslim164
Starting Member
5 Posts |
Posted - 2006-09-05 : 18:52:08
|
The statement you made makes more sense to me but im still getting an error messageError Source: Microsoft JET Database EngineError Messge: Undefined function 'GETDATE' in function.this is the actual statment in visual web developerSELECT species, trialnum, wetdate FROM mapdata WHERE (DATEDIFF([DAY], wetdate, GETDATE()) = 14)jdslim |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-09-05 : 19:29:38
|
Are you using MS Access or SQL Express? The error is thrown by the Jet Database Engine, which suggests Access. If you are using Access, then use the Date() function to get the date without a timestamp (or Now() if you need the timestamp). |
|
|
jdslim164
Starting Member
5 Posts |
Posted - 2006-09-07 : 17:16:57
|
Yes i am using MS Access. i tried the statement with DATE() and NOW(), but this is the new error. Executed SQL statement: SELECT species,trialnum,wetdate FROM mapdata WHERE (DATEDIFF([DAY], wetdate,DATE())=14)Error Source: Microsoft JET Database EngineError Messge: No value given for one or more parameters.jdslim |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-09-07 : 18:58:55
|
Look in the Access help file for the correct syntax for DateDiff(). It's not exactly the same as the SQL Server function, I think Day has to be in quotes (") and there are only certain abbreviations that are valid. |
|
|
nicku2d
Starting Member
1 Post |
Posted - 2006-10-08 : 04:00:35
|
Hi jdslim...I have the same issue with sql referencing an access database (not lettuce related though!!) did you get your datediff search to work...the correct statement would bo oh so handy!! Nquote: Originally posted by jdslim164 Yes i am using MS Access. i tried the statement with DATE() and NOW(), but this is the new error. Executed SQL statement: SELECT species,trialnum,wetdate FROM mapdata WHERE (DATEDIFF([DAY], wetdate,DATE())=14)Error Source: Microsoft JET Database EngineError Messge: No value given for one or more parameters.jdslim
Because U2D is shorter than up 2 date marketing |
|
|
X002548
Not Just a Number
15586 Posts |
|
|