Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 22nd, 2006, 12:55 AM
Friend of Wrox
 
Join Date: May 2005
Location: tehran, tehran, Iran.
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default 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

Reply With Quote
  #2 (permalink)  
Old January 22nd, 2006, 06:59 AM
Authorized User
 
Join Date: Jun 2003
Location: Dublin, , Ireland.
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

force the lcid to correspond to the local server time format.

Reply With Quote
  #3 (permalink)  
Old January 22nd, 2006, 07:55 AM
Friend of Wrox
 
Join Date: May 2005
Location: tehran, tehran, Iran.
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default


I forced but maybe it was not in the correct way.would you please explain more?

Reply With Quote
  #4 (permalink)  
Old January 22nd, 2006, 01:08 PM
Authorized User
 
Join Date: Jun 2003
Location: Dublin, , Ireland.
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
  #5 (permalink)  
Old January 23rd, 2006, 12:49 AM
Friend of Wrox
 
Join Date: May 2005
Location: tehran, tehran, Iran.
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default


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

Reply With Quote
  #6 (permalink)  
Old January 23rd, 2006, 04:04 AM
Authorized User
 
Join Date: Jun 2003
Location: Dublin, , Ireland.
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
%>

Reply With Quote
  #7 (permalink)  
Old January 23rd, 2006, 07:43 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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.
Reply With Quote
  #8 (permalink)  
Old January 25th, 2006, 03:02 AM
Friend of Wrox
 
Join Date: May 2005
Location: tehran, tehran, Iran.
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default

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

Reply With Quote
  #9 (permalink)  
Old January 25th, 2006, 03:57 AM
Authorized User
 
Join Date: Jun 2003
Location: Dublin, , Ireland.
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

google is your friend:

http://www.webwizguide.info/asp/faq/...e_settings.asp

http://www.google.com/search?sourcei...:en&q=asp+lcid

also without seeing the code is hard to know how youa are using the function. does it work for you?

Reply With Quote
  #10 (permalink)  
Old January 25th, 2006, 05:54 AM
Friend of Wrox
 
Join Date: May 2005
Location: tehran, tehran, Iran.
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default

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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DateTime Problem kwilliams ASP.NET 2.0 Professional 1 March 12th, 2008 01:36 PM
DateTime Problem!!! Pls help cmualo SQL Server 2000 4 August 17th, 2007 03:08 AM
Problem with DateTime and Textbox MAKO C# 5 July 28th, 2006 10:09 AM
DateTime problem acko Pro VB Databases 7 October 31st, 2004 05:53 AM



All times are GMT -4. The time now is 02:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.