Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2019
    Posts
    1,046

    Existing VBA data import routine does NOT store date-time as "Date" (with milli-seconds)

    Good morning:

    I kindly request some assistance with reviewing a *fully functioning* VBA data import routine (both in Access and Excel). The VBA data import routine was originally developed in Excel; however, for efficiency purposes, it was translated in Access format.

    At the present time, there is only one (1) issue with the >> DATA TYPE << ('short text' vs. 'date-time') in the Access version. Please allow me to start out with some background first.

    GENERAL BACKGROUND:
    - Attached .zip files contain 3 *sample* .LOG files (in subfolder).
    - For illustration purposes only, the number of syslog messages are limited to only {2, 3, 4}, respectively.
    - As these messy syslog formats need to be analyzed (actual logs have hundreds/thousands of messages), they require transformation into matrix format.
    - Please see attached spreadsheet "Background.xlsx" (tabs 'Before' and 'After') wrt to parsing, splitting, concatenation, and moving content.
    - The **key element** -- and reason for opening this post -- is the concatenation of the separate "date" and "time" (in log files) into a single date-time-stamp (on which calculations can be performed).

    ... so far so good (I hope). Now, for additional background purposes, it is advisable to review the attached Excel file "Import Syslogs.xlsm" (macro).

    Excel Version (with working VBA):
    - Upon opening "Import Syslogs.xlsm", click on the red command button "Import Syslogs" (in column A).
    - Navigate to the subfolder "Syslog_Samples" and select either one (1) of the three .LOG files.
    - Click "Open" will import the .LOG file into the correct and desired format (as illustrated in "Background.xls").
    - Again, please note that values in column Charlie (C) are in the required Excel format which allows to perform calculations (e.g., subtract one data from another).
    - Also, please note that the Excel VBA transformed the .LOG time from, e.g., "14:08:06:112" (hh:mm:ss:000) into Excel date-time format (mm/dd/yyyy hh:mm:ss.000) where Excel's milli-seconds are preceded with a "." (vs. ":").
    - **The latter comment referring to "milli-seconds" is the underlying issue in the Access VBA-transformed version**.

    ... now, let's review the Access VBA routine:



    Access Version (with overall working VBA):
    - File "Import Syslogs.accdb" opens the form by default.
    - Click command button "Import Syslogs" and navigate to the subfolder containing the sample log files.
    - Select/open the subfolder and click "Ok" on the browse dialogue box.
    - This imports **all 3 files ** at once (vs. in Excel where the import routine allows to process only one file at the time).
    - Based on the existing sample data all date-time stamps are inserted into [FIELD2]. (Note: I have another process which adds proper field names but that's not pertinent for this question/post)

    ... finally, here's the underlying issue:
    - [FIELD2] imported the concatenated (DATE) & (TIME) as-is (with the ":" preceding the milliseconds with data type = "Short Text".
    - Therefore, in contrast to the Excel's VBA routine, I cannot perform any calculations on this field.

    My question:
    - How should the Access VBA routine be modified to ensure proper importing of the date-time-stamp content into date format (including milliseconds)?

    Overall, I hope the VBA won't have to be fully restructured to accomplish it. Instead, I am hopeful it only requires some slight "tweaking" of the existing routine.

    Thank you for your help in advance,
    Tom
    Attached Files Attached Files

  2. #2
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    Quote Originally Posted by skydivetom View Post
    My question:
    - How should the Access VBA routine be modified to ensure proper importing of the date-time-stamp content into date format (including milliseconds)?
    Times are stored in Access with an accuracy in seconds. It is therefore not possible to record a time in milliseconds.
    See https://learn.microsoft.com/en-us/of...-datetime-data for more information on how date/time fields are stored.
    Groeten,

    Peter

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Tom,

    You might be able to use Date/Time Extended depending on your version of Access and any related systems you may interact with. I have not used it.

  4. #4
    Join Date
    Feb 2019
    Posts
    1,046
    Peter:

    Thank you for referencing this article. I wasn't aware of it. Kinda interesting that Microsoft allows the milli-seconds component in Excel but not in Access.

    That said, I still would have to tweak the VBA so that the date + time (hh:mm:ss) moved by ingested in date/time format.

    Any thoughts on how to modify the code so that it would a) strip off the milli-seconds and b) then insert/store the values in the desired date/time format?

    Thank you,
    Tom

  5. #5
    Join Date
    Feb 2019
    Posts
    1,046
    Jack:

    Thank you for chiming in... I will have to further review both articles (referenced by you and Peter).

    At first glance though, it seems like that Access *does* allow storing milli-seconds. Again, I just glanced through the articles but haven't fully digested the information yet. Anyhow, if that's true, it would make sense given both Excel 2019 AND Access 2019 are part of the Office Suite.

    More to follow.

    Thanks,
    Tom

    P.S. I use Access 2019 (article starts out by referencing "Microsoft 365 | Access 2021"

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You might get some insight from this thread. I haven't found examples of use of DateTime extended. There seems to be confusion in posts where it is mentioned. Here's another thread -older, but advising caution.
    I also found this youtube video by Maria Barnes (I have not watched it).
    Also, I am not an Excel person.

  7. #7
    Join Date
    Feb 2019
    Posts
    1,046
    Jack -- all good stuff. Had a quick peek at the additional articles. Trying to catch up w/ some "honey-do items" today but I hope to find time later on today.

    Again, thanks for sharing.

    Cheers,
    Tom

    P.S. I did open the YouTube video (your posted link) and fast-forwarded a few minutes into the video. Seems like it **might** be working in Access 2019 as well. See attached JPG... I just opened my DB to look for the setting. It's there but I haven't played with it yet. I'll go back and watch the video in its entirely (or critical elements).
    Attached Thumbnails Attached Thumbnails DateTimeExtended.jpg   DTE.jpg  

  8. #8
    Join Date
    Feb 2019
    Posts
    1,046
    Quick follow-up to my post #7.

    - After deleting my (example) *text* dates I changed the FIELD2's data type to "Date/Time Extended".
    - From the provided spreadsheet, I copied a sample value (to retain Excel's format).
    - It set the milli-seconds to all ".0000000000" (I may be off w/ respect to # of zeros).
    - Then, for testing only, I entered some arbitrary milli-seconds.
    - The Table did store them and brought them up correctly in a query.

    So, now that we have figured out that Access CAN store dates/time with milli-seconds, I go back to my original question of "how should I modify the existing VBA" IOT to automatically convert the milli-seconds (with a preceding colon) and add/append them as, e.g., ".12300000".

    I'll be away from my computer for a moment and will continue to investigate it later on. If anyone has some suggestions, I'd certainly welcome ideas.
    Attached Thumbnails Attached Thumbnails DateTimeExtended.jpg  

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 07-16-2021, 11:36 AM
  2. Like pulling tenths of seconds "Time"?
    By clebergyn in forum Programming
    Replies: 2
    Last Post: 07-16-2015, 04:48 PM
  3. Replies: 3
    Last Post: 12-06-2014, 03:59 AM
  4. Replies: 2
    Last Post: 09-29-2012, 11:22 PM
  5. Access Date/Time....I need a "generic" date.
    By beastmaster in forum Access
    Replies: 2
    Last Post: 12-29-2005, 12:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums