Solved

Win 8 dates displayed incorrectly (SQL 2008)

Posted on 2014-04-21
22
260 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
  • 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
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

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

813 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

11 Experts available now in Live!

Get 1:1 Help Now