Solved

Bizarre date transformation...

Posted on 2006-07-05
5
284 Views
Last Modified: 2012-06-27
Suddenly the dates on my page are displayed as DD/MM/YYYY. How it happened, I'm not sure. What's wierd is that they're listed correctly in the database (MM/DD/YYYY), but they're displayed as DD/MM/YYYY on my page. How can I fix this? I need MM/DD/YYYY displayed consistently.

Thanks!
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 33

Accepted Solution

by:
sajuks earned 500 total points
ID: 17047881
did u change ur isp/server or in COntrol panel > Date tab, Regional settings  did u set the date format as dd/mm/yyyy ?

you can put the below page directive on the top of ur page:

<%@LANGUAGE="VBSCRIPT" LCID="1033" %>

for ex
' For US Date Format mm/dd/yyyy
Session.LCID = 1033
Respose.write(Now)

' For UK date format dd/mm/yyyy
Session.LCID = 2057
Response.Write(Now)

Check Response.LCID  at
 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/076fa614-d397-4817-8c9a-2ece2046310b.asp
0
 

Expert Comment

by:Clobyn
ID: 17049113
I just want to add one comment: there is no "listed correct in the database", assuming you use datetime and not varchar/text fields. Datetime fields are stored in an internal format. When you view a date field with Enterprise manager/Query analyzer/in Access, the date is _presented_ according to a locale (specified on the server, in the connection string, and possibly other places).
0
 
LVL 12

Expert Comment

by:Preece
ID: 17051062
This works also:

response.write gfGetFormattedDateTime3()

'//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Function gfGetFormattedDateTime3()
  dim strServerTime
  dim strMM
  dim strDD
  dim strYYYY
      
  strServerDateTime = Now()
      
  strMM = DatePart("M", strServerDateTime)
  strDD = DatePart("D", strServerDateTime)
  strYYYY = DatePart("YYYY", strServerDateTime)

  if len(strMM) = 1 then
    strMM = "0" & strMM
  end if
  if len(strDD) = 1 then
    strDD = "0" & strDD
  end if

   gfGetFormattedDateTime3 = strMM & "/" & strDD & "/" & StrYYYY
End Function
0
 
LVL 12

Expert Comment

by:Preece
ID: 17051095
I just read your post again.  Try this:

response.write gfGetFormattedDateTime3("now", "")
or
response.write gfGetFormattedDateTime3("value", oRS("datefield"))


'//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Function gfGetFormattedDateTime3(strWhich, strDate)
  dim strServerTime
  dim strMM
  dim strDD
  dim strYYYY
     
  if strWhich = "now" then
    strServerDateTime = Now()
  else if strWhich = "value" then
    strServerDateTime = strDate
  end if
     
  strMM = DatePart("M", strServerDateTime)
  strDD = DatePart("D", strServerDateTime)
  strYYYY = DatePart("YYYY", strServerDateTime)

  if len(strMM) = 1 then
    strMM = "0" & strMM
  end if
  if len(strDD) = 1 then
    strDD = "0" & strDD
  end if

   gfGetFormattedDateTime3 = strMM & "/" & strDD & "/" & StrYYYY
End Function

Preece
0
 

Author Comment

by:brucegust
ID: 17051777
I had used a script earlier that had set the Session to read the date as DD/MM/YYYY so even after I had eliminated that line of code, the Session remained intact so that's why I kept seeing that nonsense.

Thanks for the input!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Call a function within the ASP code 4 26
Obtaining data on ASP 8 36
ASP and Looping Thru a XML Document 4 33
How to post data to an API using ASP Classic 3 31
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question