This is a discussion on "very annoying DATES" within the Classic ASP section. This forum, and the thread "very annoying DATES are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
very annoying DATES
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|
|
|||
|
Most likely that database that you are using is incorrectly configured to US (usually the default) or is hosted in the States
If you're using MS Access or SQL than you might try CONVERTing or CASTing the date to a UK format before specifiying the sort order. I'd advise whenever working with dates between a webpage and a databse to always supply them in this format: dd monthname yyyy ex. 13 May 2005. This method will store the correct date in the database independently of its configuration. Similalry when oulling the dates from the database, as mentioned before, get the converted to the correct format first by the query. |
|
||||
|
but how can i use a convert method in a SELECT statement?
also, the database stores it in the correct way of dd/mm/yyyy hh:ss so why does it not order it properly? |
|
|||
|
MS Access or MS SQL database?
|
|
|||
|
both use slightly different SQL.
The Format function is what you'll need for MS Access: http://www.techonthenet.com/access/f...ate/format.htm |
|
||||
|
can anyone explain to me why i get data type mismatch in criteria expression on the following line:
set rs = conn.Execute("SELECT * FROM ftopics2 ORDER BY cdate(lastupdated) DESC") lastupdated is a text field with the format "14 May 2005 12:24" in it.... |
|
||||
|
ok this is making no sense whatsoever!!!! it works for SQL statements but not for others...
|
|
|||
|
CDate() is a VBScript Function
In SQL you need to do CONVERT(datetime, lastupdated) I don't know why you are not just storing your date/time data in a datetime field? No matter what the setup of SQL, it'll still be a valid date, you just pull it out and reformat it in your vbscript. |
|
||||
|
storing it as a date didnt work for some reason it always displayed them in a funny order.
i get this error now: undefined function CONVERT in expression.... |
|
|||
|
Sorry, didn't read some of those posts inbetween, CONVERT is a MSSQL function, won't work in Access.
I still dont think it should matter what country your dates are in, you should still be able to CDate in VBScript and then FormatDateTime to the way you want them, or even do Day(Date) MonthName(Month(Date)) Year(Date) etc... to extract the proper parts of the field in the proper order. |
|
||||
|
its not the storing of the dates that is the problem - its displaying them. it doesnt display them in the correct order whatever i do....
|
|
|||
|
Store the dates as dates int he database, and when you pull them out, put them through this function
|
|
||||
|
it still doesnt store them in the correct order though... posts on the 13th may come after posts on the 11th which they shouldnt....
|
|
|||
|
What does your query look like?
You ought to have
|
![]() |
| Tags |
| annoying, dates |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP dates | simonb | PHP Forum | 11 | Sep 5th, 2007 14:30 |
| Days between 2 Dates | birdy247 | JavaScript Forum | 1 | Apr 19th, 2007 19:55 |
| printing out dates | riotman | Classic ASP | 0 | May 23rd, 2006 20:47 |
| dates in SQL | spinal007 | Databases | 3 | Nov 10th, 2004 09:32 |
| dates | benbacardi | Classic ASP | 2 | Sep 14th, 2004 16:18 |