Date Format Conflict

Results 1 to 3 of 3

Thread: Date Format Conflict

  1. #1
    Join Date
    Dec 1969

    Default Date Format Conflict

    I have some entries in a site database entered last week on 1st of June, the date value is being genrated automatically in the asp page by putting theDate=#"& Date &"# into the sql string which is working as desired. The date has been stored in the database as 06/01/03. <BR><BR>The problem arises attempting to show the date in an asp page list of dates. When I try to show it in long date format using &#060;%Response.write FormatDateTime(rs("theDate"), 1) it show the date up on the page as 6th January 2003 instead of 1st June 2003.<BR><BR>I know this is most likely due to conflict of U.S. (mm/dd/yy) and United Kingdom (dd/mm/yy) date formats. How can I rectify my code (or database) so that the correct date values are produced? (The database field is set to short date, if I change that to long date format should it solve the problem?)

  2. #2
    Join Date
    Dec 1969

    Default RE: Date Format Conflict

    Try the LCID something like:<BR><BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;%Session.LCID = 1033%&#062;<BR><BR>I think 1033 is US but better double check!<BR><BR>Vlince

  3. #3
    Join Date
    Dec 1969

    Default You are dead wrong...

    ...when you say "The date has been stored in the database as 06/01/03."<BR><BR>Not so AT ALL.<BR><BR>Read this:<BR><BR><BR>That will also answer your question about short date vs. long date. Hint: There ain&#039;t no such thing, not really.<BR><BR>*HOWEVER* you are correct that the problem is that Access *ONLY* understands USA format and ISO format dates when you use the #xxx# form for entering dates.<BR><BR>HOWEVER...on top of that, though, if you use a date of (example) #30/6/03# *then* Access realizes the 30 is too big to be a month number and makes that be #30 June 2003#.<BR><BR>So if you have been putting dates in using #dd/mm/yy# format, you are likely hosed already. Since all those late May dates are going to be correct and all the early June dates will be wonkers.<BR><BR>It&#039;s too bad you didn&#039;t test this first or ask here first. The *best* solution with Access is to use ISO format date:<BR><BR>&#060;%<BR>Function ISODate( dt )<BR> If Not IsDate(dt) Then <BR> ISODate = 0 &#039; or = Date() or whatever you want for default<BR> Exit Function<BR> End If<BR> dt = CDate(dt)<BR> ISODate = Year(dt) & "-" & Month(dt) & "-" & Day(dt)<BR>End Function<BR>%&#062;<BR><BR>Since this is the *ONLY* format the MySQL uses, and just incidentally works with Access, SQL Server, and Sybase (among other DBs), it ought to be part of the standard stable of tricks for all ASP users.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts