How to insert Date field through insert Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I tried to insert a record Which contain Date.
From Textbox I am assigning the value to the Query.
Like this code.....,
===========>
strSQL = "Insert INTO My_Table (name, In_Date) Values ('" & txtName &"',

# txtDate #)"
conn.execute strSQL
<===========
For Date, the value is not assigning. How can i give the format for Date
textbox?
any one can help me please....

Thanks in advance.!
 
Karthikeyan said:
I tried to insert a record Which contain Date.
From Textbox I am assigning the value to the Query.
Like this code.....,
===========>
strSQL = "Insert INTO My_Table (name, In_Date) Values ('" & txtName
&"',

# txtDate #)"
conn.execute strSQL
<===========
For Date, the value is not assigning. How can i give the format for
Date textbox?
any one can help me please....

Thanks in advance.!

strSQL = "Insert INTO My_Table (name, In_Date) Values ('" & txtName &"', #" &
txtDate & "#)"
 
Rick Brandt said:
strSQL = "Insert INTO My_Table (name, In_Date) Values ('" & txtName &"',
#" & txtDate & "#)"

<picky>

strSQL = "Insert INTO My_Table (name, In_Date) " & _
"Values ('" & txtName &"', #" & _
Format(txtDate, "mm\/dd\/yyyy") & "#)"

or

strSQL = "Insert INTO My_Table (name, In_Date) " & _
"Values ('" & txtName &"', #" & _
Format(txtDate, "yyyy\-mm\-dd") & "#)"

</picky>

Some people use dd/mm/yyyy as their Short Date format, so the original
suggestion won't always work.
 
Thanks for ur Clear and Detail Explanation..
I got the solution

-Karthikeyan P
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top