?
Solved

How do I insert the current date into Access?

Posted on 2004-04-11
10
Medium Priority
?
674 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 53

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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 53

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 53

Assisted Solution

by:Ryan Chong
Ryan Chong earned 360 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 440 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 53

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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

770 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