Date always being displayed as dd/mm/yyyy

jenn5175
06-27-2002, 02:46 PM
Okay, this may seem like a dumb question - how can I consistantly get the date displayed as mm/dd/yyyy? I have never had this problem before. I have a simple form which inserts 6 dates into a SQL database table with datetime fields. Now sometimes when I put for example 6/27/2002 in the textbox, it will insert it. Sometimes it will send it to the database as 27/6/2002 so that the database rejects it. I was getting frusterated so I simplified the test a bit using "date()": sometimes when I response.write date() or now() I get 6/27/2002. Then on a random refresh of the page it will begin displaying it as 27/6/2002 - but even when it is doing this day(date()) will still pull the correct day - 27 out so IIS KNOWS which part is the day and which is the month, it just switches them. Also I have tried using dateformat() to no avail. It still comes out as 27/6/2002 when it decides it wants to. I have checked my server's regional settings to assure the dateformat is "mm/dd/yyyy". Is there somewhere else I could check on the server besides that? How about in IIS? I cannot find a pattern to when it is switching so I am utterly confused. The page will work fine sometimes for an hour, sometimes for 5 minutes. But once it switches to dd/mm/yyyy I have not yet seen it switch back to mm/dd/yyyy. I am thinking it is a server setting somewhere because I have written code like this many times and never ran across this issue - however we just built a new webserver a few weeks ago. Any help would be MUCH appreciated!!!

Jenn

Derek Stone
06-27-2002, 08:15 PM
sDate = Format(Month(Now), "00") & "/" & Format(Day(Now), "00") & "/" & Year(Now)


Good Luck
-CL

jenn5175
06-28-2002, 06:24 AM
Yeah, I attempted that but could not get the database to see it as a date - it still gave the error "varchar cannot be converted to datetime blah blah blah" when I tried to insert it. Thanks though!

I found a solution/workaround which I think may have cured it (although not correctly). I forced the language to be English(US) by including the line

Session.LCID = 1033

at the top of my code. So far things have been going good, but I would still like to know what is truly wrong so I'm still open to suggestions!!!

Jenn

Derek Stone
06-28-2002, 01:53 PM
I'm not aware of the level at which a client's localization settings affect the server's date/time functions, however that may be the case. That's why I've always used the code that I posted above, storing it in a regular text field in a database in the following format: 20020628 (year-month-day). This allows me to format the date as I wish when its extracted from the database as well as the ability to sort recordsets as they're returned. I centralize all my date/time functions in an include file, and it creates a system that is both reliable and easy to use.

Good Luck
-CL

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum