"Bon" <bo***********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Dear all
How can I convert a datetime in Short Date format to General Date
format and then insert into SQL database?
I get a date from a field using Request("in_date"), which is in Short
Date format. Afterwards, I need to convert it into General Date and
then insert the date into database. But, the date is always inserted as
1/1/1900. Please give me some suggestions.
I would not convert it yourselves. A difference in the country setting of
SQL and your current thread on ASP could cause difficulties already.
Set cmd = CreateObject("ADODB.Command")
'samples, assume field2 and field1 dates
set cmd.activeconnection = myconn
cmd.commandtext = "INSERT INTO myTable(field1, field2) VALUES(?,?)"
cmd.commandtype =1
cmd.parameters.append cmd.createparameter(, 135,,,CDate(mydate))
cmd.parameters.append cmd.createparameter(, 135,,,#1-1-2025#)
cmd.execute ,, 128