Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Dates in a SQL Statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NateBuckley - 30 May 2008 15:40 GMT
Hello,

I'm using ADODB to connect to an ACCESS database I've set up. I have a few
fields that are Date types and I send the SQL statement via a string, the
thing is I'm getting errors when trying to use Variables that are dates in
the string.

My SQL Statement

strSQL = "SELECT * FROM tblMain WHERE [fldDateFrom] = '" & dateFrom & "'"

it'll turn my variable dateFrom into just a string. So doesn't match up when
it comes to putting this value into the database.

Anyway to make sure this gets put in as a Date type?

Sorry If that's unclear.

Nate
Andrew Taylor - 30 May 2008 15:59 GMT
I would use the following:
strSQL = "SELECT * FROM tblMain WHERE [fldDateFrom] = '" &
Format(dateFrom,"yyyy-mm-dd") & "'"

On 30 May, 15:40, NateBuckley <NateBuck...@discussions.microsoft.com>
wrote:
> Hello,
>
[quoted text clipped - 15 lines]
>
> Nate
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.