Forums
This topic is locked
Problem in Insert Record
Posted 20 years ago
1
has voted
20 years ago Nasi Koliandri posted:
Hi!I am having this code: <input type="hidden" name="textfield5" value="<%=now()%>"> in order to insert in my database (SQL Server) the current datetime. The problem is: Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting datetime from character string.
How can I do it so it would be possible to insert (automatically) the current datetime in a field in my dtabase??
Thanks!
Replies
Replied 20 years ago
20 years ago Vince Baker replied:
There is a function in Access and MS SQL that allows a default value to be entered into the field in your table.
You can set this to be the date ( i think the code is date() ).
This way, you do not get any date config problems.
The other way to do this on the page as you are trying is to set the location code on the page, this will ensure that the date is in the format you want.... for example, if you add the following line before the html opening tag in your page:
<% setlocale(2057) %> you will set the page to the uk format (dates, times etc) but bare in mind that you must not do this if you have a form on the page collecting a date from a user and that user is possibly in a different country.
If you do not have a date field other than your hidden one it is fine to use the setlocale code.
If you are not in the uk, then you will need to find you locale country code, use this link to find you code:
www.w3schools.com/vbscript/func_setlocale.asp
Regards
Vince
DMX Talkzone Manager
Visit my home: www.chez-vince.com
(Now completely CSS based and bye bye to all tables!)
VBScript | ASP | HTML | CSS | SQL | Oracle | Hosting
You can set this to be the date ( i think the code is date() ).
This way, you do not get any date config problems.
The other way to do this on the page as you are trying is to set the location code on the page, this will ensure that the date is in the format you want.... for example, if you add the following line before the html opening tag in your page:
<% setlocale(2057) %> you will set the page to the uk format (dates, times etc) but bare in mind that you must not do this if you have a form on the page collecting a date from a user and that user is possibly in a different country.
If you do not have a date field other than your hidden one it is fine to use the setlocale code.
If you are not in the uk, then you will need to find you locale country code, use this link to find you code:
www.w3schools.com/vbscript/func_setlocale.asp
Regards
Vince
DMX Talkzone Manager
Visit my home: www.chez-vince.com
(Now completely CSS based and bye bye to all tables!)
VBScript | ASP | HTML | CSS | SQL | Oracle | Hosting