Solved

How do I insert the current date into Access?

Posted on 2004-04-11
10
630 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
Comment Utility
Make Now() the default for that column.
0
 
LVL 1

Author Comment

by:QLJ
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
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
 
LVL 49

Expert Comment

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

Author Comment

by:QLJ
Comment Utility
hmm.. this doesnt solve the problem. The SysDate and SysTime field remains empty in the database
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 49

Assisted Solution

by:Ryan Chong
Ryan Chong earned 90 total points
Comment Utility
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
Comment Utility
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
Comment Utility
>>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 49

Expert Comment

by:Ryan Chong
Comment Utility
Now more clear, QLJ ?
0
 
LVL 1

Author Comment

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Read about achieving the basic levels of HRIS security in the workplace.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now