|
-
August 24th, 1999, 06:12 AM
#1
Compare Dates within an SQL command
I have two dtpicker controls where the user selects 2 dates: "from" and "to".
Then I have a database where I want to select all dates between this space:
Dates >= "from" and <= "to"
How may I syntax the SQL command?
Is this right?:
dim strSQL_WHERE as string
strSQL_WHERE = " P_FLD4 <= " & Format$(CStr(frmMain.DTPicker2.Value), "yyyy-mm-dd") & " AND P_FLD4 >= " & Format$(CStr(frmMain.DTPicker1.Value), "yyyy-mm-dd")
-
August 24th, 1999, 07:00 AM
#2
Re: Compare Dates within an SQL command
IMHO this depends on your backend and the settings you use for that.
e.g in SQLServer you can use SET DATEFORMAT to define the format of your dates.
Anyway, you need quotes around your date values as in:
...where date1 <= '" & format... & "' and date1 >= '" & format... & "'"
-
August 24th, 1999, 07:09 AM
#3
Re: Compare Dates within an SQL command
My syntax is right. The problem is not there. The problem is how to COMPARE the dates? Is there any special way with SQL commands?
I found for example something like this:
{d '1999-08-24')
But how I use it?
I use VB6 Enterprise SP3 and the database is Paradox4 (I have created a connection with ODBC32bit DataSources -> System DSN). Nothing more...
Michael Vlastos
Automation Engineer
Company Modus SA
Development Department
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
|