|
-
Apr 17th, 2002, 04:56 AM
#1
sql problem with date
Hi,
its a rookie question but my sql tag does not work
VB Code:
sqltoevoegen = "SELECT * FROM toevoegen WHERE datum BETWEEN " & Bdatum & " AND " & Edatum & " "
explaination:
toevoegen = tabel name
datum = date/time field
bdatum = dim bdatum as date
edatum = dim edatum as date
bdatum = txtbdatum.text
edatum = txtedatum.text
my problem is that he wil not look in the field. I want that I can search between two date's
-
Apr 17th, 2002, 05:08 AM
#2
Fanatic Member
first of all, are you using Access or SQL Server? secondly, what error are you getting? one thing i can see is that you gotta put single quotes around the dates (that's if you're using SQL Server, use a # if it's Access):
Code:
"SELECT * FROM toevoegen WHERE datum BETWEEN '" & Bdatum & "' AND '" & Edatum & "'"
otherwise, it's cos you're using SQL Server, and it doesn't like non-US dates by default, so you'd have to do this:
Code:
"SET DATEFORMAT DMY SELECT * FROM toevoegen WHERE datum BETWEEN '" & Bdatum & "' AND '" & Edatum & "'"
hope that helps
-
Apr 17th, 2002, 05:16 AM
#3
Tron :
Sql server uses single quotes for dates ??
What does it use from strings ?
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 17th, 2002, 05:49 AM
#4
Fanatic Member
the same
-
Apr 17th, 2002, 05:57 AM
#5
Addicted Member
VB Code:
sqltoevoegen = "SELECT * FROM toevoegen WHERE datum BETWEEN #" & Bdatum & "# AND #" & Edatum & "# "
my code gifs the next problems
-
Apr 17th, 2002, 06:04 AM
#6
Addicted Member
sorry: i have yest press the wrong buttom
VB Code:
sqltoevoegen = "SELECT * FROM toevoegen WHERE datum BETWEEN #" & Bdatum & "# AND #" & Edatum & "# "
my code gifs the next problems
when i select by days smaller then 10 it fails
a solution would by to set the date american but i havend thry this.
when you have got the wright solution please tel me now.
thanks.
Heribertt
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|