Results 1 to 6 of 6

Thread: Comparing dates before transferring data from Access DB to Excel (ADO)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    17

    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.

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    17

    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?

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  6. #6
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width