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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB-Access-SQL Date format problem help please

Status
Not open for further replies.

sdh

Programmer
Joined
Apr 30, 2001
Messages
121
Location
GB
I have a database (Access) which has a table in it created with the following sql statement in vb code

sqltext = "CREATE TABLE Reports (ID COUNTER CONSTRAINT Recid PRIMARY KEY, RepDate datetime,report_name text,"
sqltext = sqltext & " Userid text, Country text,Unit text,Yr text(2),Wk text(2),Reptype text,Repdesc text,Path text,access text)"


when i run the query from vb using the statement below I return nothing even though there are reports in there that match the date can anyone tell me why?

sqltext = "Select * from reports where Repdate=#" & Date & "#"

please can someone help this is driving me up the wall.
sdh ::-)
 
Try this!

sqltext = "Select * from reports where Repdate=#" & CStr(Format(Date, "yyyy-mm-dd")) & "#"

DR
 
Thanks Diogo works perfectly.
However I would like to understand why.

what do I need to create a string in that format?

sdh::-)
 
In your sqltext you have a string field and a date field.
Whith the command cstr i'm converting a date field to a string.

DR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top