Saving Dates, M/D/Y H:M:S

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CoreyReynolds
    New Member
    • Nov 2009
    • 29

    Saving Dates, M/D/Y H:M:S

    Hello,

    I have been running an SQL Insert to save some data into a table, here is the applicable snippet of the tail end of that insert where the date is added:

    Code:
    finalString = finalString & "'" & addString & "', '" & Format(Now, "MM/DD/YY hh:mm:ss") & "')"
    It will only save the date as MM/DD/YYYY format in the access table though, but I need greater accuracy down to the seconds. I've tried using the Date function as well to no luck. In access the field in the table is a General Date, with no input mask set (although I've tried making an input mask that would include everything and it didn't seem to help), and everything else is default.

    Thanks!
  • patjones
    Recognized Expert Contributor
    • Jun 2007
    • 931

    #2
    Hi,

    Have you tried specifying the same format ("MM/DD/YY hh:mm:ss") in the table's design view, for the column in question?

    Pat

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32662

      #3
      People often overcomplicate working with date/times.

      Try :
      Code:
      finalString = finalString & "'" & addString & "',Now()"
      I've no idea why your date/time field is showing only the date data. It's probably down to your trying to assign it a string value, so I expect this to fix it. Otherwise it's probably not a storage (assignment) problem at all, but rather a display one.

      Let us know how you get on with this.

      Comment

      • CoreyReynolds
        New Member
        • Nov 2009
        • 29

        #4
        I swapped out my "Date" with Now() and specified the format and it worked.

        So basically both of your solutions combined worked :)

        Thanks to both of you!

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32662

          #5
          A pleasure Corey.

          Dates are a concept that are often misunderstood when it comes to storing, displaying and converting. Once the basics are properly understood however, it's really not too difficult to master.

          Comment

          • DataAnalyzer
            New Member
            • May 2010
            • 15

            #6
            The date field is really a double with a date format on top of it. If you examined the value of the data field, you'll see that the days are integers, and the decimal side is the % of day (e.g.. 0.5 = 12 hours).

            Comment

            Working...