Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with basic SELECT statement

Status
Not open for further replies.

majordog

Programmer
Jul 8, 2002
222
CA
Hey,
I would like to base my query on a date the user inputs. The field in the database smalldatetime, also records the time. I want to get all the records on a specific date regardless of the time.

Below is what I have, with txtDate = 12/19/2002

SELECT * FROM vTestEditor WHERE DatePerformed =" & CDate(txtDate.Text)

What method can I use to stipulate that I want the date search without time being a factor?

Thanks guys -
 
hi,
If you want just the date use.

SELECT * FROM vTestEditor WHERE DatePerformed =" &
CDate(Format(txtDate.Text,"mm/dd/yyyy"))

rann.

 
That won't help much, since the times are in the database, not the txtDate field.

Either use JohnYingling's example, or look into your database documentation to what it uses for a CDate() type of function. For instance, in SQL Server you could do something like

SELECT * FROM vTestEditor WHERE convert( varchar(10),DatePerformed,101)=" & CDate(txtDate.Text)
 

Some Other ways (note the single quotes)

SQLServer
"SELECT * FROM vTestEditor WHERE convert(varchar, DatePerformed, 1) = '" & CDate(txtDate.Text) & "'"

Access

"SELECT * from dbo_tbls_qtm WHERE datediff("d", DatePerformed, '" & CDate(txtDate.Text) & "') =0 "



Mark
 
Thanks all, much appreciated - and the database was SQL Server
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top