PC Review


Reply
Thread Tools Rate Thread

Dates in SQL query won't match

 
 
Gustaf
Guest
Posts: n/a
 
      22nd Apr 2008
I'm importing data from Access into Excel. At one point, I need to import dates, and for some reason they don't match.

month = CDate(Cells(1, iCol))
....
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM Occupancy WHERE [Month] = " & month, cn, adOpenKeyset, adLockOptimistic

I have 3 records in Occupancy where Month is 2008-04-01. When the month variable is also 2008-04-01, I still get 0 on rs.RecordCount! The month is stored as a Date/Time (short date) in Access. I also tried

WHERE [Month] = " & Format(month, "yyyy-mm-dd")

Still no success.

Gustaf
 
Reply With Quote
 
 
 
 
Gustaf
Guest
Posts: n/a
 
      22nd Apr 2008
Gustaf wrote:
> I'm importing data from Access into Excel. At one point, I need to
> import dates, and for some reason they don't match.


Found it. I need to write

WHERE [Month] = #" & month & "#"

Gustaf
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
match one column with dates to several colums with dates, copy pas Torben Microsoft Excel Programming 4 3rd Nov 2008 04:10 PM
Windows explorer dates to match Word dates John Microsoft Word Document Management 0 17th Oct 2005 11:43 PM
Windows explorer dates to match Word dates John Microsoft Word Document Management 0 17th Oct 2005 11:30 PM
Windows explorer dates to match Word dates John Microsoft Word Document Management 1 17th Oct 2005 09:26 PM
Windows explorer dates to match Word dates John Microsoft Word Document Management 1 16th Oct 2005 10:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:53 AM.