inserting date into a table with visual basic

hello,
I want to insert the date into a table with visual basic, i defined the date column to be Date type, I want to take the date from the machine by using Now() function that returns both date and time, I tried using Format function to get only the date:  Format (Now, "short date") but I got the following compiler error: "Can't find project or library"
which library do I need to inlude in order to use this function?
thanx.
LVL 1
zolpoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
Hi zolpo,

What database are you using, for access it would be something like:

"Insert Into MyTable MyField,MyDateField Values('My Value',#" & Format(Now(),"yyyy-mm-dd") & "#)"

For MS SQL it would be

"Insert Into MyTable MyField,MyDateField Values('My Value','" & Format(Now(),"yyyy-mm-dd") & "')"

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
rajaamirapuCommented:
Go to Project references and see wheather there any missing libararys/DLLS/TLBS in your project.Include the missing libararys and then complie this solves your problem
0
TimCotteeHead of Software ServicesCommented:
As a note, the reason for using yyyy-mm-dd rather than short date is a simple one, especially if you are using MS Access. yyyy-mm-dd gives you effectively an unambiguous date format that will always be correctly interpreted when it is stored. MS Access is peculiar in that it will *ONLY* accept dates when they are passed in the american format mm/dd/yy regardless of the locale short date or long date setting. This can cause significant confusion and complication if you do not allow for it in this way.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

zolpoAuthor Commented:
TimCottee, Thanks for your replay!
I wrote the query as u said, but my problem was the compiler error I got when using the Format function,
I'm using visual basic enterprise edition with Access 97,
the compiler gives the error on the following line i wrote:
hour = Format (Now, "short date") and marks the word "Format", the error i get is a run time error, "Compiler error : can't find project or library"
thanx

0
rajaamirapuCommented:
Go to Project references and see wheather there any missing libararys/DLLS/TLBS in your project.Include the missing libararys  
0
s_sarigulCommented:
That's the SQL

STSQL="Insert Into <TABLE> (First_Date) Values(CDATE( ' "+Cstr(Date)+" ' ))"
 
0
zolpoAuthor Commented:
rajaamirapu thanks,
what libraries do i need to include in order to use Format function???
(I searched the web for examples of using format function but non of them used any include)
0
rajaamirapuCommented:
Any libraries are missing in the references it will show the missing ones with missing:librarary name.
0
rajaamirapuCommented:
in the references dialog.
0
zolpoAuthor Commented:
rajaamirapu,
I looked at the project refrences the missing libraries are:
Missing: Microsoft DAO 3.6 Object library
Missing: Microsoft activeX data objects (multi dimensional).....
I dont think that these libraries are connected to my problem,
however,
the library: Microsoft data formatting object is NOT missing, that's the library (I think) I need to use Format()
thanks
0
rajaamirapuCommented:
Include those libraries and see
Missing: Microsoft DAO 3.6 Object library
Missing: Microsoft activeX data objects (multi dimensional).....
This is because VB 6.0 will show complie error like that only.I had this problem before and i solved it by including those
Thanks
0
Richie_SimonettiIT OperationsCommented:
Your problem is with VBA.dll, some is corrupted or missing, maybe you have installed some new stuff recently. Try to locate that dll from your office installation, after that, unregister that dll, delete from the system, copy new one and re-register it.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rajaamirapuCommented:
Is the version of Microsoft activeX data objects (multi dimensional) is 2.5?
0
zolpoAuthor Commented:
rajaamirapu
nope, it's 2.6
thanks
0
rajaamirapuCommented:
Include Microsoft activeX data objects (multi dimensional) is 2.6 and try
0
Richie_SimonettiIT OperationsCommented:
"....
hour = Format (Now, "short date") and marks the word "Format", the error i get is a run time error, "Compiler error : can't find project or library"
...."
Format function is included in VBA.dll (As all other string functions)
Cheers
0
Richie_SimonettiIT OperationsCommented:
Also Now(), by the way.
0
ghermeCommented:
Hi
You can get the date using Date function (dd-mm-yyyy) then use the format
0
Richie_SimonettiIT OperationsCommented:
Date function belongs to VBA.dll too.
0
EDDYKTCommented:
Is any reason you have include another reference that has format in

try to use

hour = VBA.Format (Now, "short date")
0
zolpoAuthor Commented:
Thanks You All !
the problem was with the installation,
I re-install some stuff and it worked.
Thanks again
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.