Solved

Bizarre date transformation...

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now