?
Solved

Win 8 dates displayed incorrectly (SQL 2008)

Posted on 2014-04-21
22
Medium Priority
?
266 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:Aleks
  • 13
  • 7
21 Comments
 

Author Comment

by:Aleks
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 54

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 1752 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:Aleks
ID: 40013270
It reads '0'. What should I set it to ?
Attached how dates are displayed.
pageASP.gif
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

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

Assisted Solution

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

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

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 1752 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 248 total points
ID: 40013353
0
 

Author Comment

by:Aleks
ID: 40013365
The script shows:

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

Author Comment

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

Author Comment

by:Aleks
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 54

Assisted Solution

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

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

or

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

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 1752 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:Aleks
ID: 40013835
What should it read ?
0
 

Author Comment

by:Aleks
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:Aleks
ID: 40013840
trying ...
0
 

Author Comment

by:Aleks
ID: 40013845
Problem..

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

shows:   4/25/2014

Should be:  04/25/2014
0
 

Author Comment

by:Aleks
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:Aleks
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 54

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 1752 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 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 1752 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:Aleks
ID: 40013889
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

809 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