Home / Software / Computer programming / Comparing Date Values between Excel and Access (ADO)
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: Comparing Date Values between Excel and Access (ADO)  (Read 854 times)
keyven
Guest
« on: April 19, 2007, 03:32:38 AM »

Is there a simple way to make identical the date format between Excel and Access ... i'm assuming there must be, but I can't seem to figure it out.

Basically, I need to take 2 Dates from Excel and 1 from an Access DB, and check them against each other... and if it passes, the record will be copied onto the Excel Worksheet.

Can anyone give me advice on how to get started with this... :) thank you~
IP logged
keyven
Guest
« Reply #1 on: April 19, 2007, 04:06:35 AM »

dteTo is a Short-Date formatted cell in Excel
datess is a field in Access

dteTo = Range("D28").Text

(1)
strQuery = "SELECT * FROM testTable1 WHERE datediff( ""d"", datess, ""02/02/2007"") = 0;"

(2)
strQuery = "SELECT * FROM testTable1 WHERE datediff( ""d"", datess, dteTo) = 0;"

1st one is ok, error for the 2nd one - 'No value given for one or more required parameters'

Someone pls help identify what is going on here... thank you~
IP logged
Sidewinder
Guru



Thanked: 97
Posts: 4,341

Experience: Familiar
OS: Windows 7

« Reply #2 on: April 19, 2007, 05:50:38 AM »

This one of those problems where you know something is wrong but just can't see it. Actually I'm suprised example 1 worked, date literals are usually surrounded by # signs.

Quote
dteTo is a Short-Date formatted cell in Excel

I'm pretty sure the datatypes are mismatched and that by using the text property, something got messed up.

Try using dteTo = Range("D28").Value

You might try using Range("D28").Value directly in the DateDiff function or as a last resort using the CDate function to guarantee all the fields are converted to dates.

Good luck. 8)

PS. VB and VBA are not very forgiving when it comes to mismatched datatypes.

IP logged

If you don't know where you are going, any road will get you there

                                                                            -Lewis Carroll
Pages: [1] - (Top) Print 
Home / Software / Computer programming / Comparing Date Values between Excel and Access (ADO) « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.105 seconds with 20 queries.