Comparing dates before transferring data from Access DB to Excel (ADO)
I'm guess I need to transfer the info into a buffer (recordset?), do the comparison, then only extract the relevant data to Excel? Is there a simpler way of doing this? And does anyone have links to examples?
Must the Format be identical (eg. Long Date vs Long Date, or can it be like Long Date vs Short Date) when it comes to comparing dates?
Furthermore, when i use the preset MM/DD/YYYY, whenever i enter a date like '10/12/2006' (12 Oct), it automatically reverts to '12/10/2006'... and if i enter 12/15/2006' (15 Dec), it doesn't seem to recognise the date at all! (btw, i'm using British settings for win xp)
Thanks in advance... need all the help i can get.
Re: Comparing dates before transferring data from Access DB to Excel (ADO)
What's your tentative select query? And what's the data type in the database? If the data type in the database is string then you will have to manually or progmatically parse the string to get the months and days.
Re: Comparing dates before transferring data from Access DB to Excel (ADO)
Quote:
Originally Posted by leinad31
What's your tentative select query? And what's the data type in the database? If the data type in the database is string then you will have to manually or progmatically parse the string to get the months and days.
strQuery = "SELECT " & JobNo & ", " & JobName & " FROM " & "tblJobs" _
& " WHERE " & jobDate... (incomplete)
Basically, is it possible to have the End-user input 2 dates into Excel Cells, and the ADO extracts the relevant data based on whether the DB's jobDate is inbetween them?
So basically the ADO must address both Excel and Access in comparing the date values... have any good, simple examples?
Re: Comparing dates before transferring data from Access DB to Excel (ADO)
Excel has a copyfromrecordset method, search the method for sample code.
The WHERE clause depends on the data type of the relevant fields.
Re: Comparing dates before transferring data from Access DB to Excel (ADO)
If your localization is British, dates must be in dd/mm/yyyy format. Is this being written in Access VBA, Excel VBA, VB6, VB.net? A datepicker control or two, if available, would be your best bet.
Re: Comparing dates before transferring data from Access DB to Excel (ADO)
DateTime is datetime regardless of formatting... that's why he has to specify whether he used strings to store the dates (which will involve additional processing) or datetime.