Photoshop Contest Forum Index - Ask the Experts - Any ASP coders that can answer this? - Reply to topic
TofuTheGreat
Location: Back where I belong.
|
Tue May 01, 2007 11:55 am Reply with quote
I've been working on a ASP web application for work (note ASP not ASP.Net). The system is very dependent on two entered dates and the differences between those two dates.
When I attempt to use DateDiff() I'm getting wacky results. If I put in 5/2/2007 (May 2nd, 2007) and 5/19/2007 (May 19th, 2007) I get a result of something to the order of 103 days difference. It's like the function is treating the first date as January 5th instead of May 1st. This is happening in spite of my regional settings on the server.
Any site coders out there that know why this is and how to get around it?
Also if I have the input boxes of my form set to default a date it's coming in the format of "5.2.2007" instead of "5/2/2007". Again this is contrary to the regional settings on the computer.
Note: I've posted this to a Usenet group but I'm hoping that someone here will know the issue (ahem, Azionite, Showcase, etc.). Also ASP using VBScript is not my choice for scripting. It's an order.
_________________ Why I do believe it's pants-less o'clock! - Lar deSouza
”The mind is like a parachute, it doesn’t work if it isn’t open.” - Frank Zappa
Created using photoshop and absolutely no talent. - reyrey
|
|
Tue May 01, 2007 12:05 pm Reply with quote
TofuTheGreat wrote: I've been working on a ASP web application for work (note ASP not ASP.Net). The system is very dependent on two entered dates and the differences between those two dates.
When I attempt to use DateDiff() I'm getting wacky results. If I put in 5/2/2007 (May 2nd, 2007) and 5/19/2007 (May 19th, 2007) I get a result of something to the order of 103 days difference. It's like the function is treating the first date as January 5th instead of May 1st. This is happening in spite of my regional settings on the server.
Any site coders out there that know why this is and how to get around it?
Also if I have the input boxes of my form set to default a date it's coming in the format of "5.2.2007" instead of "5/2/2007". Again this is contrary to the regional settings on the computer.
Note: I've posted this to a Usenet group but I'm hoping that someone here will know the issue (ahem, Azionite, Showcase, etc.). Also ASP using VBScript is not my choice for scripting. It's an order.
*Ahem... Does this help at all:
Are you specifying which part of the date you are comparing (day, month, year..)
http://www.asp101.com/samples/viewasp.asp?file=y2k.asp
Oh, and make sure that whatever you are comparing is being cast as a date (CDate function) before you're comparing it. I'm not sure if DateDiff will handle string dates the same as Dates...
|
TofuTheGreat
Location: Back where I belong.
|
Tue May 01, 2007 12:11 pm Reply with quote
Azionite wrote:
Yep. Shoulda posted some code huh?
Code:
dim ArrivalDate, DepartureDate, NumNights
ArrivalDate = request.form("txtArrivalDate")
DepartureDate = request.form("txtDepartureDate")
NumNights = Datediff("d", cdate(ArrivalDate),cdate(DepartureDate))
Also this is IIS 5 on a Win2k Server.
_________________ Why I do believe it's pants-less o'clock! - Lar deSouza
”The mind is like a parachute, it doesn’t work if it isn’t open.” - Frank Zappa
Created using photoshop and absolutely no talent. - reyrey
|
TofuTheGreat
Location: Back where I belong.
|
Tue May 01, 2007 3:26 pm Reply with quote
Az PM'd me with a few suggestions. This was the result for anyone that is curious.
I added this little snippet before my original code
Code: 'Testing variables
dim CurrentDate, NextDate
CurrentDate = Date()
response.write(CurrentDate & "<br>")
NextDate = DateAdd("d", 4, CurrentDate)
response.write("4 Days from now is " & NextDate & "<br>")
response.write("The difference of those two dates is " & datediff("d", cdate(CurrentDate), cdate(NextDate)) & "<br/>")
Everything worked as it's supposed to. INCLUDING my original code. I commented out the response.write statements and everything still works. I comment out that whole snippet and things still work.
That's literally the only changes I made to the code. Shocked
I think I'll have a chat with the netadmin and see if he's been messing with my test server.
Either way it's working now, for the moment, so I guess I'm going to leave as-is until it breaks again.
_________________ Why I do believe it's pants-less o'clock! - Lar deSouza
”The mind is like a parachute, it doesn’t work if it isn’t open.” - Frank Zappa
Created using photoshop and absolutely no talent. - reyrey
|
armogeden
Location: The other side of your screen
|
Tue May 01, 2007 3:51 pm Reply with quote
TofuTheGreat wrote: I have a problem
Reboot! Reboot!
|
TofuTheGreat
Location: Back where I belong.
|
Tue May 01, 2007 3:52 pm Reply with quote
It broke again. All I did is shut down my browser and then go back in. Tried to run the same dates and it goes sideways again.
I hate ASP.
_________________ Why I do believe it's pants-less o'clock! - Lar deSouza
”The mind is like a parachute, it doesn’t work if it isn’t open.” - Frank Zappa
Created using photoshop and absolutely no talent. - reyrey
|
TofuTheGreat
Location: Back where I belong.
|
Tue May 01, 2007 5:15 pm Reply with quote
Ugh. Seems that any date that can be taken two ways (basically the 1st through 12th of all the months) will through a monkey wrench into the system.
Now I have to figure out how to validate whether a date is in mm/dd/yyyy format, dd/mm/yyyy format, or yyyy/mm/dd format. What a pain in the buttocks.
_________________ Why I do believe it's pants-less o'clock! - Lar deSouza
”The mind is like a parachute, it doesn’t work if it isn’t open.” - Frank Zappa
Created using photoshop and absolutely no talent. - reyrey
|
|
Tue May 01, 2007 5:47 pm Reply with quote
I say...spin around really really fast and then STOP...and the solution will appear before you.
|
supak0ma
Location: Photoshop Nation
|
Wed May 02, 2007 3:47 am Reply with quote
a solution is to put day, month, year in different input fields.
TofuTheGreat wrote: Ugh. Seems that any date that can be taken two ways (basically the 1st through 12th of all the months) will through a monkey wrench into the system.
Now I have to figure out how to validate whether a date is in mm/dd/yyyy format, dd/mm/yyyy format, or yyyy/mm/dd format. What a pain in the buttocks.
|
TofuTheGreat
Location: Back where I belong.
|
Wed May 02, 2007 10:44 am Reply with quote
supak0ma wrote: a solution is to put day, month, year in different input fields.
TofuTheGreat wrote: Ugh. Seems that any date that can be taken two ways (basically the 1st through 12th of all the months) will through a monkey wrench into the system.
Now I have to figure out how to validate whether a date is in mm/dd/yyyy format, dd/mm/yyyy format, or yyyy/mm/dd format. What a pain in the buttocks.
An easier solution is to require yyyy/mm/dd format only. But this is the US midwest. People are too used to mm/dd/yyyy.
I'm currently trying out a script that generates a calendar that people can click on to set the arrival and departure dates. Should take some of the idiot factor out (I can only hope).
_________________ Why I do believe it's pants-less o'clock! - Lar deSouza
”The mind is like a parachute, it doesn’t work if it isn’t open.” - Frank Zappa
Created using photoshop and absolutely no talent. - reyrey
|
TofuTheGreat
Location: Back where I belong.
|
Wed May 02, 2007 2:05 pm Reply with quote
supak0ma wrote:
Well now that's a wicked cool idear!
This thing has been really odd.
I had a script that built a table and populated it with a calendar. At the top of the calendar the month name would appear thanks to the MonthName() function built into VBScript. I ran the script and the month names come out in Finnish instead of English.
So I've resorted to completely rebooting the server and trying again. I think I'll go with a custom script as the max range for reservations is 14-days. So I'll script a calendar that lets them click the arrival date and then it auto adjusts so that only the next 13 days are clickable for setting the departure date. Plus I can color code it for the range since there is a discount for reserving in 5-day blocks.
_________________ Why I do believe it's pants-less o'clock! - Lar deSouza
”The mind is like a parachute, it doesn’t work if it isn’t open.” - Frank Zappa
Created using photoshop and absolutely no talent. - reyrey
|
Photoshop Contest Forum Index - Ask the Experts - Any ASP coders that can answer this? - Reply to topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|