How to insert Date field through insert Query

  • Thread starter Karthikeyan Periasamy
  • Start date
K

Karthikeyan Periasamy

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.!
 
R

Rick Brandt

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 & "#)"
 
D

Douglas J. Steele

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.
 
K

Karthikeyan Periasamy

Your idea is working fine
Thanks for ur Kindly help...,
-Karthikeyan P
 
K

Karthikeyan Periasamy

Thanks for ur Clear and Detail Explanation..
I got the solution

-Karthikeyan P
 
Top