Solved

How do I insert the current date into Access?

Posted on 2004-04-11
10
655 Views
Last Modified: 2008-02-01
Hi,
 I have this form online and I want to be able to write the date and time of submission into this access database that I have. How do i do it?
In my database, the field should be of type date/time or what?

Thanx
0
Comment
Question by:QLJ
  • 4
  • 4
  • 2
10 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 10803425
Make Now() the default for that column.
0
 
LVL 1

Author Comment

by:QLJ
ID: 10803917
sqlStr = "Insert into Feedback(FirstName,LastName,Designation,CompanyName,Position,Email,Contact,Feedback,SysDate,SysTime) & Values ('" & request("firstname") & "', '" & request("lastname") & "', '" & request("radiobutton") & "', '" & request("company") & "', '" & request("position") & "','" & request("email") & "','" & request("number") & "','" & request("feedback") & "')"

say I want to enter the date and time into the db(SysDate, SysTime), what should I do?

the now()works fine if I just want to display, but when I try to insert, nothing is inserted. I was wondering what might have gone wrong...
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 10804389
Try this:

sqlStr = "Insert into Feedback(FirstName,LastName,Designation,CompanyName,Position,Email,Contact,Feedback,SysDate,SysTime) & Values ('" & request("firstname") & "', '" & request("lastname") & "', '" & request("radiobutton") & "', '" & request("company") & "', '" & request("position") & "','" & request("email") & "','" & request("number") & "','" & request("feedback") & ", Date(), Time()')"
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 50

Expert Comment

by:Ryan Chong
ID: 10804391
>>In my database, the field should be of type date/time or what?
Yes, exactly.
0
 
LVL 1

Author Comment

by:QLJ
ID: 10810015
hmm.. this doesnt solve the problem. The SysDate and SysTime field remains empty in the database
0
 
LVL 50

Assisted Solution

by:Ryan Chong
Ryan Chong earned 90 total points
ID: 10810973
Opps! Typo.. try this again?

sqlStr = "Insert into Feedback(FirstName,LastName,Designation,CompanyName,Position,Email,Contact,Feedback,SysDate,SysTime) & Values ('" & request("firstname") & "', '" & request("lastname") & "', '" & request("radiobutton") & "', '" & request("company") & "', '" & request("position") & "','" & request("email") & "','" & request("number") & "','" & request("feedback") & "', Date(), Time())"


if still doesnt work (shouldnt be), try as what acperkins already suggested:

Go to the Table Design Window, select the Feedback table, select the file SysDate, set it's Default Property to =Date(), and then select the SysTime field, set it's Default Property to =Time()

then change your statement to:

sqlStr = "Insert into Feedback(FirstName,LastName,Designation,CompanyName,Position,Email,Contact,Feedback) & Values ('" & request("firstname") & "', '" & request("lastname") & "', '" & request("radiobutton") & "', '" & request("company") & "', '" & request("position") & "','" & request("email") & "','" & request("number") & "','" & request("feedback") & "')"

Hope this works
0
 
LVL 1

Author Comment

by:QLJ
ID: 10811313
oh no.. your first method doesnt work

>>Go to the Table Design Window, select the Feedback table, select the file SysDate, set it's Default Property to =Date(), >>and then select the SysTime field, set it's Default Property to =Time()

Which field do you mean? in the Format field of the Field Properties?

ps. Thanx for the effort! (even though it is of measly points) Decided to up it to make it up to you!
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 110 total points
ID: 10812720
>>Which field do you mean? in the Format field of the Field Properties?<<
No, not the Format, but (as I suggested previously) the Default Value.
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 10819704
Now more clear, QLJ ?
0
 
LVL 1

Author Comment

by:QLJ
ID: 10829330
hey.. thanx guys! it worked! I'm a happy person! :)
sorry acperkins, din really get what you meant initially. :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about achieving the basic levels of HRIS security in the workplace.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question