+ Reply to Thread
Results 1 to 8 of 8

loosing the hhmmss when exporting datetime to Microsoft Access through macro (vba and SQL)

  1. #1
    Registered User
    Join Date
    02-04-2018
    Location
    Canberra, Australia
    MS-Off Ver
    2013
    Posts
    74

    loosing the hhmmss when exporting datetime to Microsoft Access through macro (vba and SQL)

    Hi All,

    I'm using excel to export data from a CSV file to Microsoft Access.

    One of the fileds is datetime (3/01/2019 12:02:00 AM). I can import the data into Access manually and the hhmmss remains however when I run it through the macro it is dropping off the hhmmss.

    I have attached a sample CSV file, the import spreadsheet and a test Access database (sorry can't attach the Access file).

    The data for 02/01/2019 and 03/01/2019 have been manually imported into Access and the data for 04/01/2019 has been imported through Excel.

    the project called DataLoad does the loading work and ADOFuncs does the db connection work.


    Any help is appreciated as it is driving me crazy.

    Cheers

    Dean


    This is what is imported into Access (03/01/2019 manually imported and 04/01/2019 imported from Spreadsheet)
    AccessPic.JPG
    Attached Files Attached Files
    Last edited by DeanMcK; 01-06-2019 at 11:55 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: loosing the hhmmss when exporting datetime to Microsoft Access through macro (vba and

    Have not looked at your file, but often, when importing data, numbers (and dates/time are numbers) come across as text. Try converting them to date/time 1st?
    If you are not sure how to do this, let me know.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    02-04-2018
    Location
    Canberra, Australia
    MS-Off Ver
    2013
    Posts
    74

    Re: loosing the hhmmss when exporting datetime to Microsoft Access through macro (vba and

    Hi Ford,

    The dateTime is formatted as d/mm/yyyy h:mm and the data imports fine when imported through Access.

    hhmmformat.JPG


    Cheers

    Dean

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: loosing the hhmmss when exporting datetime to Microsoft Access through macro (vba and

    If you have text date/time, that wont change no matter how you format it. Even if you format to Date, it will still stay Text.

    Try a quick test. Pick a date and use =isnumber() on it
    eg =isnumber(A1)
    if you get FALSE, you have a text date and it will need to be converted.

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: loosing the hhmmss when exporting datetime to Microsoft Access through macro (vba and

    When updating the date from excel cell value use VBA Format function to include the date & time.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  6. #6
    Registered User
    Join Date
    02-04-2018
    Location
    Canberra, Australia
    MS-Off Ver
    2013
    Posts
    74

    Re: loosing the hhmmss when exporting datetime to Microsoft Access through macro (vba and

    Hi Ford,

    Thanks for your assistance on this one.


    When I run the =isnumber I get TRUE

    If I import straight into Access it is imported as Date Type Date/Time

    ISNumber.JPG


    Cheers

    Dean

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: loosing the hhmmss when exporting datetime to Microsoft Access through macro (vba and

    But in your attached screenshot time is showing as 0:00

  8. #8
    Registered User
    Join Date
    02-04-2018
    Location
    Canberra, Australia
    MS-Off Ver
    2013
    Posts
    74

    Re: loosing the hhmmss when exporting datetime to Microsoft Access through macro (vba and

    HiFord,

    That particular line was midnight so shows time as 0:00.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 08-12-2015, 05:45 PM
  2. Add Microsoft Access Object Library reference without installed Microsoft Access
    By nichchap in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2014, 08:36 AM
  3. Excel Macro for exporting rows to Access 2007
    By Joshua_Babcock in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-25-2012, 01:55 PM
  4. Macro that opens access and auto fills input boxes before exporting.
    By CJPHX in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2010, 09:26 AM
  5. exporting excel to access macro
    By student56 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-06-2008, 01:38 PM
  6. datetime format issues when linking access to excel
    By Season in forum Excel General
    Replies: 0
    Last Post: 12-06-2005, 01:00 PM
  7. [SOLVED] Need Excel macro for exporting data to Access
    By halfshoe in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-18-2005, 06:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1