Solved

Bizarre date transformation...

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Issue with Loop 4 57
Update table value with join syntax 2 69
Copy only dates 3 89
Select case on click 3 16
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…
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/…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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