Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Dates in SQL query won't match

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Dates in SQL query won't match

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
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
Index, match, multiple IFs query zx6roo Excel Worksheet Functions 9 May 8th 10 08:46 AM
How to list the rows that match a particular query? david.karr Excel Discussion (Misc queries) 2 May 4th 10 11:47 PM
Text match from web query andrew Excel Discussion (Misc queries) 0 July 8th 08 03:27 AM
index and match query kate Excel Worksheet Functions 1 August 7th 06 12:59 AM
INDEX AND MATCH QUERY ? kate Excel Worksheet Functions 2 July 17th 06 01:19 PM


All times are GMT +1. The time now is 07:12 PM.

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"