Solved

Win 8 dates displayed incorrectly (SQL 2008)

Posted on 2014-04-21
22
262 Views
Last Modified: 2014-04-23
This is in my development computer. I have SQL 2008 R2 installed and I had win 7 with IIS installed.
My classic ASP application was running just fine. I have a script that formats the dates and it would display mm/dd/yyyy.
Then I upgraded to win 8, same code, same script, same database, only now the dates are displayed as dd/mm/yyyy

This is rather annoying because the ASP will validate all the dates to be mm/dd/yyyy so every time I hit 'update' I get an error.

Why is windows 8 doing this ?  My clock date is mm/dd/yyyy so that's not it.

Any ideas ?
0
Comment
Question by:amucinobluedot
[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
  • 13
  • 7
22 Comments
 

Author Comment

by:amucinobluedot
ID: 40013232
BTW ... this is constant, I have 3 computers, as soon as I upgraded them to win 8 ALL 3 have the same issue, so it is NOT the ASP code. If run under win 7 works fine.
0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 438 total points
ID: 40013255
You need to set the LocalID.  Log into IIS, click on ASP and see the LocalID.  What is that set to?

http://support.microsoft.com/kb/229690
0
 

Author Comment

by:amucinobluedot
ID: 40013270
It reads '0'. What should I set it to ?
Attached how dates are displayed.
pageASP.gif
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:amucinobluedot
ID: 40013274
I set it to '1033' with the same result.
0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 438 total points
ID: 40013319
What happens if you just use

<%
response.write now
response.write "<br>"
response.write formatdatetime(now,2)
%>
0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 438 total points
ID: 40013331
Try this...

1) Go to your control panel

2) Click on Clock, Language and Region

3) Change Date, Time Format

I think that is where you can change to mm/dd/yyyy
0
 
LVL 16

Assisted Solution

by:joinaunion
joinaunion earned 62 total points
ID: 40013353
0
 

Author Comment

by:amucinobluedot
ID: 40013365
The script shows:

4/21/2014 4:19:13 PM
4/21/2014
0
 

Author Comment

by:amucinobluedot
ID: 40013366
Read that .. didn't fix anything
0
 

Author Comment

by:amucinobluedot
ID: 40013367
This is my script:

I display with:
<%= DoDateTime((Comments.Fields.Item("Lastupdate").Value), 2, 9225) %>  </p>

---

<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>					
function DoDateTime(str, nNamedFormat, nLCID)				
	dim strRet								
	dim nOldLCID								
										
	strRet = str								
	If (nLCID > -1) Then							
		oldLCID = Session.LCID						
	End If									
										
	On Error Resume Next							
										
	If (nLCID > -1) Then							
		Session.LCID = nLCID						
	End If									
										
   If ((nLCID < 0) Or (Session.LCID = nLCID)) Then                        
            strRet = FormatDateTime(str, nNamedFormat)                  
            strRet = Right("0" & Datepart("m",strRet),2) & "/" & Right("0" & Datepart("d",strRet),2) & "/" & DatePart("yyyy",strRet)
End If 									
										
	If (nLCID > -1) Then							
		Session.LCID = oldLCID						
	End If									
										
	DoDateTime = strRet							
End Function									
</SCRIPT>

Open in new window

0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 438 total points
ID: 40013483
Try

<%= formatdatetime((Comments.Fields.Item("Lastupdate").Value), 2) %>

or

<%= DoDateTime((Comments.Fields.Item("Lastupdate").Value), 2, 1033) %>
0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 438 total points
ID: 40013488
The problem is not in your windows machine or iis, it is with your script.   You are formatting to English(Caribbean)

See the link I gave you for reference
      strLCID = 9225  &apos; English(Caribbean)"?>
0
 

Author Comment

by:amucinobluedot
ID: 40013835
What should it read ?
0
 

Author Comment

by:amucinobluedot
ID: 40013837
I don't see any reference to that. This is the script:

<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>					
function DoDateTime(str, nNamedFormat, nLCID)				
	dim strRet								
	dim nOldLCID								
										
	strRet = str								
	If (nLCID > -1) Then							
		oldLCID = Session.LCID						
	End If									
										
	On Error Resume Next							
										
	If (nLCID > -1) Then							
		Session.LCID = nLCID						
	End If									
										
   If ((nLCID < 0) Or (Session.LCID = nLCID)) And IsDate(str) Then                       
            strRet = FormatDateTime(str, nNamedFormat)                  
            strRet = Right("0" & Datepart("m",strRet),2) & "/" & Right("0" & Datepart("d",strRet),2) & "/" & DatePart("yyyy",strRet)
End If 									
										
	If (nLCID > -1) Then							
		Session.LCID = oldLCID						
	End If									
										
	DoDateTime = strRet							
End Function									
</SCRIPT>

Open in new window

0
 

Author Comment

by:amucinobluedot
ID: 40013840
trying ...
0
 

Author Comment

by:amucinobluedot
ID: 40013845
Problem..

<%= DoDateTime((Alarms.Fields.Item("Schdemailon").Value), 2, 1033) %>

shows:   4/25/2014

Should be:  04/25/2014
0
 

Author Comment

by:amucinobluedot
ID: 40013850
Funny .. if I use this script instead it works fine, even with the 9225 ... how is that possible ?

<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>					
function DoDateTime(str, nNamedFormat, nLCID)				
	dim strRet								
	dim nOldLCID								
										
	strRet = str								
	If (nLCID > -1) Then							
		oldLCID = Session.LCID						
	End If									
										
	On Error Resume Next							
										
	If (nLCID > -1) Then							
		Session.LCID = nLCID						
	End If									
										
   If ((nLCID < 0) Or (Session.LCID = nLCID)) And IsDate(str) Then                       
            strRet = FormatDateTime(str, nNamedFormat)                  
            strRet = Right("0" & Datepart("m",strRet),2) & "/" & Right("0" & Datepart("d",strRet),2) & "/" & DatePart("yyyy",strRet)
End If 									
										
	If (nLCID > -1) Then							
		Session.LCID = oldLCID						
	End If									
										
	DoDateTime = strRet							
End Function									
</SCRIPT>

Open in new window

0
 

Author Comment

by:amucinobluedot
ID: 40013854
This one gives the weird date

---

<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>					
function DoDateTime(str, nNamedFormat, nLCID)				
	dim strRet								
	dim nOldLCID								
										
	strRet = str								
	If (nLCID > -1) Then							
		oldLCID = Session.LCID						
	End If									
										
	On Error Resume Next							
										
	If (nLCID > -1) Then							
		Session.LCID = nLCID						
	End If									
										
	If ((nLCID < 0) Or (Session.LCID = nLCID)) Then				
		strRet = FormatDateTime(str, nNamedFormat)			
	End If									
										
	If (nLCID > -1) Then							
		Session.LCID = oldLCID						
	End If									
										
	DoDateTime = strRet							
End Function									
</SCRIPT>

Open in new window


---

Plus .. something also weird is that IT DOES WORK in win 7 and windows server, while on win 8 I get the date error ???

Makes no sense to me
0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 438 total points
ID: 40013859
Your code here is supposed to be padding

Try and change
if ((nLCID < 0) Or (Session.LCID = nLCID)) Then                        
            strRet = FormatDateTime(str, nNamedFormat)                  
            strRet = Right("0" & Datepart("m",strRet),2) & "/" & Right("0" & Datepart("d",strRet),2) & "/" & DatePart("yyyy",strRet)
End If 

Open in new window

     
To
if ((nLCID < 0) Or (Session.LCID = nLCID)) Then                        
            strRet = FormatDateTime(str, 2)                  
            strRet = Right("0" & month(strRet)) & "/" & Right("0" & month(strRet)) & "/" & DatePart("yyyy",strRet)
End If 

Open in new window

0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 438 total points
ID: 40013872
The function, DoDateTime is messing you up.  There is no need for that.  If you use my first suggestion you will be better off.

<%= formatdatetime((Comments.Fields.Item("Lastupdate").Value), 2) %>

Open in new window



Or for padding

<%

tempDate= formatdatetime((Comments.Fields.Item("Lastupdate").Value), 2) 
tempMonth=right("0"&month(tempDate)
tempDay=right("0"&day(tempDate)
newDate=tempMonth&"/"&tempDay&"/"&year(tempDate
response.write newDate
%>

 

Open in new window

0
 

Author Comment

by:amucinobluedot
ID: 40013889
Thanks
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to count occurrences of each item in an array.
This Micro Tutorial will teach you how to reformat your flash drive. Sometimes your flash drive may have issues carrying files so this will completely restore it to manufacturing settings. Make sure to backup all files before reformatting. This w…

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