Forum Moderators: open
I'm using the POST method on the first page.
Say the input is named "edtDate". (The test is run on the IIS server PC, regional settings are dd/mm/yyyy).
On the second page I use:
OrdDate = Request.Form("edtDate")
Response.Write("The date = " & OrdDate & "; The Day part is = " & Day(OrdDate))
If I enter "23/07/2005" on the first page, the output is:
The date = 23/07/2005; The Day part is = 23
OK, all's well...
If I enter "01/07/2005" on the first page, the output is:
The date = 01/07/2005; The Day part is = 7
Huh? Wassssup?
Anyone have a idea? Please....
<select name = "month">
<option value = "1">January</option>
<option value = "2">February</option>
...
</select>
<select name = "day">
<option value = "1">1</option>
<option value = "2">2</option>
...
</select>
<select name = "year">
<option value = "2005">2005</option>
<option value = "2006">2006</option>
...
</select>
After a bit of thinking round the issue.. I did this:
OrdDate = Request.Form("datOrd")
dtOrdDate = FixDate(OrdDate)
Function FixDate(TargetDate)
if Day(TargetDate) < 13 then
dtDate = Month(TargetDate)
dtMonth = Day(TargetDate)
else
dtDate = Day(TargetDate)
dtMonth = Month(TargetDate)
end if
FixDate = dtDate & "/" & dtMonth & "/" & Year(TargetDate)
End Function
Yup, I know it's about as elegant as a swift kick in the @#$'s, but it works...
What interests me, is how I can find no real, clean, proper fix for something which is obviously a bug in the ASP.dll? Thanks again, Bill :))
That way you will know that the second figure will always be the Day, or the Month, depending on the locale you set. I learned this the hard way when a host apparently changed the localeID of the server, despite insisting they didn't, and all my dates appeared as if from Klingon.
Once you have set the LocalID, then construct your form with three different fields [eg, day/month/year] and plaster the format on the form in BIG LETTERS to make sure your users input correctly - well, most of them anyway.
Onya
Woz
something which is obviously a bug in the ASP.dll
Erm, yeah.... obviously! 8-)
It sounds to me like your server's regional settings are set to US. Have a look, and change them to GB/UK.
I wouldn't use your fudge code unless you can absolutely help it. When you change servers, it will more than likely mess up again.
Firstly, may I just say thank you. This has to be the most responsive forum I have ever used to get help.
Background. I'm primarily a Delphi developer. I work alone, no one to lean over to and ask, no mentor. I got into ASP after my ASP sub-contractor let me down by 3 weeks and almost torpedo'd my relationship with an excellent customer..so I hit the books and the web, and here I am. So what a pleasure to find a forum where everyone is up to help, esp the senior guys. Thanks.
Mattglet: I have Delphi, ASP, ISAPI in my box. I use Java sparingly, cos I can't write or debug it. I wish I could, but...
Woz: I did the web search thing, found the article on MSDN, and tried setting both Session and Response LCID. No change. Remember the results are not consistently mm/dd/yyyy or dd/mm/yyyy, but change as the day reaches 13. So 01/07/2005 returns day = 7 month = 1, and 14/07/2005 returns day = 14 month = 7.
MrMister: First place I looked. Interestingly the server was set to yyyy/mm/dd. Tried setting it to dd/mm/yyyy and mm/dd/yyyy. No difference. Seems to be ignoring that setting completely. That's when I went looking for a way to force the issue and found the LCID settings, which also made no difference. I agree wholeheartedly about using fudge code, I do, really :) But I have a customer posting accounting system entries using the ASP right now, so my time to research is under pressure. I promise not to let it lie there tho'
I'll probably do the three fields thing in ASP or a Delphi ASP component to fix it properly and permanently as soon as I can.
Thanks again, and I hope I'll be able to help someone else like you guys have helped me. I'll be baaak :)