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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date into Access DB failure 1

Status
Not open for further replies.

ralphonzo

Programmer
Apr 9, 2003
228
GB
Trying to insert a date into the access database and it's driving me barmy. I'm sure I've done this before.

variable:
Code:
whatnow = day(date)&"\"&month(date)&"\"&year(date)

SQL statement:
Code:
sql=""
sql=sql&"INSERT INTO students (sname1, sname2, semail, smembership, spass, saddress, sdatereg) VALUES ('"&visitor&"', '"&visitor2&"', '"&visitormail&"', 1, '"&dcode&"', 'none', "&whatnow&")"
%><%=sql%><%
conn.execute(sql)

SQL output:
Code:
INSERT INTO students (sname1, sname2, semail, smembership, spass, saddress, sdatereg) VALUES ('Ralph', 'Test', 'ralph@test.com', 1, 'sNA9f214', 'none', 20\10\2010)

DB date output when redisplayed:
Code:
30\12\1899 or 00:01:26


I've tried using #s and converting to 'string' but nothing seems to get around it. How can I get the date to register properly?
 
Thanks Candyman, but that just gives me a different time! :eek:|

Foxbox, I had a much better delve into the linked site that you sent, and got the dratted thing working. God knows why it used to work and then stopped doing so...almost as bad as PHP!!!

Thanks Tek-tips once again!
 
whatnow = day(date)&"\"&month(date)&"\"&year(date)
try forward slash "/" instead of backward slash "\
 
dates in access always have #
i tried it with forward slash and #
and it worked ok on insert.
try this:
Code:
INSERT INTO students (sname1, sname2, semail, smembership, spass, saddress, sdatereg) VALUES ('Ralph', 'Test', 'ralph@test.com', 1, 'sNA9f214', 'none', #10/20/2010#)
 
That's cool, thanks. I actually gt it to work by using hyphens. I'll forward slash it in future though :eek:|
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top