I have an access table and I want to insert today's date into one of the field. What is the correct syntax.
This is not working:
Dim todaysdate as String
todaysdate = format(Now,"m/d/yy")
Insert into table(Date)Values(todaysdate)
Thanks
Printable View
I have an access table and I want to insert today's date into one of the field. What is the correct syntax.
This is not working:
Dim todaysdate as String
todaysdate = format(Now,"m/d/yy")
Insert into table(Date)Values(todaysdate)
Thanks
What seaweed has said is right, the only thing is, it is to be used in Client/Server database, not Access.
GetDate function is a Transact SQL function, but in Access you CAN use Date(), Time(), Now() functions. Just bear in mind that you can not use the function by itself, i.e:
You have to use it in combination with a real fields, i.e:Code:Select Date() As MyDate From MyTable
Code:Select FieldName, Date() As MyDate From MyTable
Well, I deleted my first reply because I re-read the question and saw that he was talking about Access, not SQL server. It's been a while since I've done access, but I'm looking into it now...
~seaweed
Hi..
I've inserted a date once using SQL and VB, And you have to do something freaky..
Make sure the SQL looks something like this:
SQL = "insert into Table Values( # "& date & " #)"
I cant seem to find the actual syntax (you may want to double check the double quotes and see if any single quotes are needed), but I know that you need the # before a date field for it to be properly accepted into access
hope that helps!
~Sam
Sam's got the right idea; his Syntax is correct as well.