Solved

Win 8 dates displayed incorrectly (SQL 2008)

Posted on 2014-04-21
22
258 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
Comment Utility
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
Comment Utility
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
Comment Utility
It reads '0'. What should I set it to ?
Attached how dates are displayed.
pageASP.gif
0
 

Author Comment

by:amucinobluedot
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:amucinobluedot
Comment Utility
The script shows:

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

Author Comment

by:amucinobluedot
Comment Utility
Read that .. didn't fix anything
0
 

Author Comment

by:amucinobluedot
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 438 total points
Comment Utility
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
Comment Utility
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
Comment Utility
What should it read ?
0
 

Author Comment

by:amucinobluedot
Comment Utility
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
Comment Utility
trying ...
0
 

Author Comment

by:amucinobluedot
Comment Utility
Problem..

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

shows:   4/25/2014

Should be:  04/25/2014
0
 

Author Comment

by:amucinobluedot
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
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…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

771 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

13 Experts available now in Live!

Get 1:1 Help Now