Solved

Bizarre date transformation...

Posted on 2006-07-05
5
288 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

624 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