Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date showing as 12/30/1899

Status
Not open for further replies.

btrini10

IS-IT--Management
Dec 5, 2006
73
US
strSQL = "INSERT INTO CASE_CONTACT1 (CASE_ID, CONTACT_ID, DATE_ADDED) VALUES (" & Me.CASE_ID & "," & Me.CONTACT_ID & "," & Format(strDate, "yyyy-mm-dd") & ")"

I am trying to get today's date into the Date_added field. Using the above I get 6/8/1905.

Using below I get 12/30/1899.

strSQL = "INSERT INTO CASE_CONTACT1 (CASE_ID, CONTACT_ID, DATE_ADDED) VALUES (" & Me.CASE_ID & "," & Me.CONTACT_ID & "," & Date & ")"

Can someone assist me in identifying what I am doing wrong?

Thanks
 
Hi,

Dates are just NUMBERS.

12/30/1899 is ZERO.

Code:
strSQL = "INSERT INTO CASE_CONTACT1 (CASE_ID, CONTACT_ID, DATE_ADDED) VALUES (" & Me.CASE_ID & "," & Me.CONTACT_ID & "," & Format([b]Date()[/b], "yyyy-mm-dd") & ")"

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Use either:
strSQL = "INSERT INTO CASE_CONTACT1 (CASE_ID, CONTACT_ID, DATE_ADDED) VALUES (" & Me.CASE_ID & "," & Me.CONTACT_ID & ",#" & Format(Date, "yyyy-mm-dd") & "#)"

or:
strSQL = "INSERT INTO CASE_CONTACT1 (CASE_ID, CONTACT_ID, DATE_ADDED) VALUES (" & Me.CASE_ID & "," & Me.CONTACT_ID & ",Date())"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the response guys, but I must be doing something wrong. when I try Date(), the brackets are being removed when I close my code.
PHV, when I try your first solution I get syntax error in the INSERT INTO.

Am I doing something wrong?

Thanks
 
When you use Date, are you referring to the reserved word or a field in your table? If it's a field in your table, use square brackets [Date].

Better yet, don't use reserved words as field names!


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top