Results 1 to 3 of 3

Thread: Save a timestamp towards database (Access) - SOLVED -

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Location
    Earth 4 now.
    Posts
    27

    Save a timestamp towards database (Access) - SOLVED -

    Edit: I fixed it. The problem is the field name Timestamp, it's a Reserved word. So I changed it to [Timestamp] and now it works.

    Hi,
    I'm using a Access database.
    In this database I've a table called VisitReport.
    In the table VisitReport there is a field Timestamp from the type Date/Time -> "General Date"

    Now what I want to do is save the current time towards the Timestamp field.

    I tried to use this in the querry:
    Timestamp=" & Now & " or #" & Now & "#

    and even this:
    Timestamp=#" & Year(Now) & "-" & Month(Now) & "-" & Day(Now) & " " & Hour(Now) & ":" & Minute(Now) & ":" & Second(Now) & "#

    But they return syntax errors.

    I haven't worked with general date or the Now function before so please explain to me how to do this thing.

    Thanks a lot.

    Used code:
    VB Code:
    1. sqlCreateVisitReport = "INSERT INTO VisitReport (VisitDate,
    2. CompanyName,WrittenBy,Address,VisitedBy,DFIStakeholders,ExecutiveSummary
    3. ,AgreedBusinessObjective,VisitReportFile,Presentation
    4. ,Timestamp) VALUES (#" & Year(vrdate) & "-" & Month(vrdate)
    5. & "-" & Day(vrdate) & "#,'" & accountname & "','" & writtenby
    6. & "','" & address & "','" & visitedby & "','" & dfistakeholders & "',
    7. '" & executivesummary & "','" & agreedbusinessobjective & "','" &
    8. visitreport & "','" & presentation & "', " & Now & ")"
    Last edited by ShotokanTuning; Jul 28th, 2004 at 03:32 AM.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    "', " & Now & ")"
    You need something like
    Code:
    "', #" & Now & "#)"
    You put it in for the first date, but not around the second. Try that and post up if it works.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Location
    Earth 4 now.
    Posts
    27
    Edit: I fixed it. The problem is the field name Timestamp, it's a Reserved word. So I changed it to [Timestamp] and now it works.

    Yeah thanks for your reply, indeed but I already tried that (this was a desperate attempt without the #).

    This shows the Now function does work okay:

    Code:
    Response.Write Now
    Result:
    27-7-04 13:50:39

    This is what happens with the # :

    sqlCreateVisitReport = "INSERT INTO VisitReport (VisitDate,
    CompanyName,WrittenBy,Address,VisitedBy,DFIStakeholders,ExecutiveSummary,
    AgreedBusinessObjective,VisitReportFile,Presentation,Timestamp)
    VALUES (#" & Year(vrdate) & "-" & Month(vrdate) & "-" & Day
    (vrdate) & "#,'" & accountname & "','" & writtenby & "','" &
    address & "','" & visitedby & "','" & dfistakeholders & "','" & executivesummary & "','" & agreedbusinessobjective & "','" &
    visitreport & "','" & presentation & "', #" & Now & "#)"


    Error:

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.


    I get no errors and everything works when the Timestamp and Now part are left out.

    INSERT INTO VisitReport (VisitDate, CompanyName,WrittenBy,Address,VisitedBy,DFIStakeholders,ExecutiveSummary,AgreedBusinessObjective,Vis itReportFile,Presentation,Timestamp) VALUES (#2004-1-12#,'Aquafil','','','','','','','','', #27-7-04 14:07:43#)

    This is how it looks when I only entered the first two fields. You can see the date formats are quite different maybe it's because of that?

    Thanks for trying to help me out.

    Also I'm using Session.LCID = 1043.
    Last edited by ShotokanTuning; Jul 28th, 2004 at 03:31 AM.

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