21. januar 2002 - 15:09Der er
9 kommentarer og 1 løsning
Java- og Access-datoer
Jeg bruger Access 2002 og Java. I min database har jeg et felt med en dato og et med et tidspunkt. Dvs.: Dato: short date, dvs. 11-11-2001 Tidspkt.: short time, dvs. 17:30
Nu vil jeg gerne undersøge, om en tidsfrist er udløbet. Dvs. om dags dato er større end den dato, der står i min database. Hvordan gør jeg det? Giv gerne et godt eksempel med Java-kode!!
Challengers>As I mentioned, this is Access and NOT JAVA. Giving an SQL statament in Access is not the same as JAVA and thats more than likeley the reason wht you havent received others answers.
In this example youcan see the SomeDateField is NOT within the string \"\" how this is done in JAVA is up to you and it should be formatted MM/DD/YYYY
Its years ago since I played around with C/C++ so I cant remember how to contactenate strings. Hope you get the idea!
SQLString = \"SELECT Id FROM Kampe WHERE #\" & SomeDateField & \"# > DatabaseDateField\"
Thats not right! If you want to see those where the date is > than the current date: tblDateField is the name of the column in the database and Date() gives the current date!
\"SELECT Id FROM Kampe WHERE [tblDateField] > Date();\"
Hvis jeg bruger denne sætning, opstår der en SQLException, der giver følgende meddelelse: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.