 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Dreamweaver (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

January 22nd, 2006, 12:55 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Datetime problem
Hello
I have prblem with Datetime type in SQLServer:
I have some clumns with Datetime type in my Database and an update form in Dreamweaver.i've changed the type of columns belongs to Datetime columns in Database to Date.it is working correctly in my local computer but when i upload it,gives me converting char to Datetime error when i push the updat button.even if i don't change anything.
please let me know where is the mistake.
thank you
|
|

January 22nd, 2006, 06:59 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
force the lcid to correspond to the local server time format.
|
|

January 22nd, 2006, 07:55 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I forced but maybe it was not in the correct way.would you please explain more?
|
|

January 22nd, 2006, 01:08 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
you are in Iran at the moment so your computer is setup with your localID session which works fine on insert cause the date is probably ex. dd/mm/yyyy.
ig you hosting the live version - let say in USA then the date will be mm/dd/yyyy, so by setting the insert based on the live server LCID it will change the date to their Local date format.
try to get the sql format before insert:
response.write (your sql)
response.end()
and see what format is the date on insert
|
|

January 23rd, 2006, 12:49 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You're right.the format is dd/mm/yyyy.what should i do to fixt it????
even when I insert with mm/dd/yyyy format online it changes to dd/mm/yyyy
|
|

January 23rd, 2006, 04:04 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
the best way is the use store procedures, and let SQL server update the date itself using getdate() as default value.
Another way is the force the date to change in the format the SQL takes it.
<%
'-------------------------------------------------------------------------------
' functions for default date format
' es_date_type = 0-7, where 0-4 same as vbscript
' 5 = "yyyy/mm/dd"
' 6 = "mm/dd/yyyy"
' 7 = "dd/mm/yyyy"
const es_divider = "/" ' es_divider
function es_date_time_type(es_date, es_date_type)
if isdate(es_date) then
if es_date_type >= 0 and es_date_type <= 4 then
es_date_time_type = formatdatetime(es_date, es_date_type)
elseif es_date_type = 5 then
es_date_time_type = year(es_date) & es_divider & month(es_date) & es_divider & day(es_date)
elseif es_date_type = 6 then
es_date_time_type = month(es_date) & es_divider & day(es_date) & es_divider & year(es_date)
elseif es_date_type = 7 then
es_date_time_type = day(es_date) & es_divider & month(es_date) & es_divider & year(es_date)
else
es_date_time_type = es_date
end if
else
es_date_time_type = es_date
end if
end function
%>
|
|

January 23rd, 2006, 07:43 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
In addition to this useful function, I can recommend to stick to the format yyyy/mm/dd (number 5).
That format always works to represent a date that is understood by the database, regardless of regional settings. With other formats, you always run the risk of April 3 turning into March 4 for example.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

January 25th, 2006, 03:02 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I used this fuction for changin the format of columns with Datetime type and put this exchange in event of subimt button.but i dn't know is it change those valuse or no.would you please let me know is it correct or no and introduce me a cool link for more information about LCids.i've not use DateTime untill now and i didn't know these kinds of problems. thank you
|
|

January 25th, 2006, 05:54 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you.links are very usefull.my codes are something like below and it is not working.I think used it in a very wrong way:
<script for="Submit" language="VBScript" event="OnClick">
Dim i1,..,i9
i1=rs("ActualDeliveryDateToIranCustom1")
.
.
.
i9=rs("SGSFinalApproval1")
call es_date_time_type(i1, 7)
.
.
.
.
call es_date_time_type(i9, 7)
</script>
I choose Datetpe=7 because our users use this kind.but it doesn't work.this button is in an update form.
|
|
 |