PDA

View Full Version : Riddle me this, Firefox...


Upchurch
26th July 2006, 07:14 AM
Using Firefox 1.5, I've come across an unusual error. On our live site, everything works fine, but when I view our development site (which is supposed to be nearly identical, I get an SQL error due to the fact that it is reading the date as dd/mm/yyyy instead of mm/dd/yyyy. Both sites work fine in ID, it's just devl site on Firefox.

Now I've scanned through my settings. The only extensions I have for Firefox is Google Toolbar, IE Tab, and Tab Mix Plus. The page in question gives slightly different results when viewed as Firefox or IE in Firefox, but the root cause of the error seems to be the date format.

Now, what might be causing Firefox to confuse date formats in this one case and not others?

Cleon
26th July 2006, 10:20 AM
SQL error? Could you be a bit more specific about what the page is doing?

I'm in the middle of coding a struts-based reporting app, so right now I am The Man when it comes to date formats. :)

Upchurch
26th July 2006, 10:32 AM
-2147217913

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

SQL:SELECT TOP 2 UID, AdUnitPage, AdType, PI FROM AdContent WHERE AdUnitSize='728X90' and datestart<='26/07/2006' and datestop>='26/07/2006' and datestop>='26/07/2006' and available>0 order by LastViewed;

Our asp provides this data when it encounters this kind of problem. Note the date format.

I reset all Firefox preferences and it seems to be working again. I don't know which one made the difference.

El_Spectre
26th July 2006, 10:56 AM
Sounds like the app is feeding a client side - and thus untrustworthy - date into the proc...

Cleon
26th July 2006, 03:34 PM
What ES said. I encourage you to rethink the structure of this app.

Ripley Twenty-Nine
27th July 2006, 09:00 AM
What ES said. I encourage you to rethink the structure of this app.
Especially considering if it's using the client's Date format, it might be using the client's timestamp as well. Pretty scary considering how far off most people's computers are!

Upchurch
27th July 2006, 09:18 AM
Many revisions planned, but we have to support the current system until that point. You know how it goes.

Cleon
27th July 2006, 09:31 AM
Many revisions planned, but we have to support the current system until that point. You know how it goes.

It just screams security problems, but at this point what I would do is run a Javascript function to force a format of the date.

For example, if you absolutely, positively, need a MM/DD/YYYY format, do something like this:


function formatNumber(i) {
if(i< 10) {
return("0" + i);
}
else {
return(i);
}
}

function formatDate() {
var today = new Date();
var day = today.getDate();
var month = today.getMonth() + 1; // Month is 0-based
var year = today.getYear();

// Some clients do "year" as years since 1900, eg 106
if(year < 1000) {
year += 1900;
}

var str = formatNumber(month) + "/" + formatNumber(day) + "/" + year;
return(str);
}


ETA: And for the love of Jebus, redevelop that app!!!!

Soapy Sam
29th July 2006, 04:10 PM
Many revisions planned, but we have to support the current system until that point. You know how it goes.

- The History of Civilisation , in one pithy sentence.

Rat
30th July 2006, 06:39 PM
Two sentences, surely? And only one of them particularly pithy, I'd've thought.

Cheers,
Rat.

a_unique_person
30th July 2006, 10:42 PM
What is the regional location for the machine set to? A lot of programs get the date format from that.