Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default Dates in a SQL Statement

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Dates in a SQL Statement

I would use the following:
strSQL = "SELECT * FROM tblMain WHERE [fldDateFrom] = '" &
Format(dateFrom,"yyyy-mm-dd") & "'"



On 30 May, 15:40, NateBuckley
wrote:
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statement for Dates Daren Excel Worksheet Functions 12 October 29th 08 08:50 PM
IF Statement Using Dates Jason T. Excel Discussion (Misc queries) 6 June 4th 08 04:37 PM
IF Statement with Dates. [email protected][_2_] Excel Programming 2 October 24th 07 06:14 PM
If statement with dates Vivian H. New Users to Excel 5 September 14th 06 08:27 AM
IF statement with two dates jbormann Excel Discussion (Misc queries) 2 July 18th 06 05:32 PM


All times are GMT +1. The time now is 05:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"