Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Bizarre date transformation...

Posted on 2006-07-05
5
Medium Priority
?
291 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 2000 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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