![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Known bug in CStr (Date ()) in WSH 5.7? Hi folks I've recently updated my XP laptop to SP3 which has uplifted WSH to v5.7 and this has introduced a bug regarding the Date () function. When the result is being converted to a string, it doesn't use the correct local format, but seems to default to US format instead. Here in the UK the standard format is DD/MM/YYYY. Here is some example code: WScript.Echo Date () WScript.Echo ““ & Date () WScript.Echo CStr (Date ()) Under 5.6 this produces the correct output: Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. 04/07/2008 04/07/2008 04/07/2008 Under WSH 5.7 the output is: Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved. 04/07/2008 7/4/2008 7/4/2008 This happens in both cscript.exe and wscript.exe. Is this a known bug? The main problem I have with it is that any WMI queries using the date either fail or return the wrong data. Regards Tony Longson. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Known bug in CStr (Date ()) in WSH 5.7? Tony Longson schrieb: Quote: > > I've recently updated my XP laptop to SP3 which has uplifted WSH to v5.7 and > this has introduced a bug regarding the Date () function > .... Here in the UK the standard format is > DD/MM/YYYY. Here is some example code: > > WScript.Echo Date () > WScript.Echo ““ & Date () > WScript.Echo CStr (Date ()) > > Under 5.6 this produces the correct output: Quote: > 04/07/2008 > 04/07/2008 > 04/07/2008 > > Under WSH 5.7 the output is: > > > 04/07/2008 > 7/4/2008 > 7/4/2008 german locale settings with DD.MM.YYYY as standard short date format the output is as expected: 11.07.2008 11.07.2008 11.07.2008 It might help to test WSH 5.7 on some other machines with UK locale to see if it is WSH 5.7, that fails or some system DLL or whatever. Quote: > This happens in both cscript.exe and wscript.exe. > > Is this a known bug? The main problem I have with it is that any WMI queries > using the date either fail or return the wrong data. conversion. It's much safer to use date functions such as Day, Month, DatePart, FormatDatetime etc to build a date string properly formatted. MfG, Alex |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Known bug in CStr (Date ()) in WSH 5.7? In microsoft.public.scripting.vbscript message <5CB5D3A1-78EA-4EC9-A6DD- C1D4EC1C1654@xxxxxx>, Fri, 11 Jul 2008 08:49:00, Tony Longson <Tony@xxxxxx?.microsoft.com.invalid> posted: Quote: > >I've recently updated my XP laptop to SP3 which has uplifted WSH to v5.7 and >this has introduced a bug regarding the Date () function. WSH 5.7 does NOT fix the ISO Week Number bug seen in WSH 5.1 and 5.6; details are in <URL:http://www.merlyn.demon.co.uk/vb-date2.htm#Week>, with better code. Any comment you may have on those VBS pages would be welcome. My general recommendation is never to use conversion code of US origin for converting to or from strings in non-US format; they are not trustworthy - as you will recall from their general attitude towards tea and cricket. Use DateSerial and TimeSerial to generate CDates; the extra time taken in coding substringing will be repaid (though you won't recognise it) on the first occasion on which trusting system conversion would have failed. In general, use locality-independent primitives in a locality-dependent manner, unless you MUST respond to OS settings. -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05. Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Known bug in CStr (Date ()) in WSH 5.7? On Jul 11, 4:49*pm, Tony Longson <Tony Long...@xxxxxx> wrote: Quote: > Hi folks > > I've recently updated my XP laptop to SP3 which has uplifted WSH to v5.7 and > this has introduced a bug regarding the Date () function. When the resultis > being converted to a string, it doesn't use the correct local format, but > seems to default to US format instead. Here in the UK the standard formatis > DD/MM/YYYY. 5.7 in a local Web page). Nevertheless, my previous comment still applies. -- (c) John Stockton, near London, UK. Posting with Google. Mail: J.R.""""""""@physics.org or (better) via Home Page at Web: <URL:http://www.merlyn.demon.co.uk/> FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ... |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Known bug in CStr (Date ()) in WSH 5.7? Tony Longson wrote: Quote: > Hi folks > > I've recently updated my XP laptop to SP3 which has uplifted WSH to > v5.7 and this has introduced a bug regarding the Date () function. > When the result is being converted to a string, it doesn't use the > correct local format, but seems to default to US format instead. Here > in the UK the standard format is DD/MM/YYYY. JScript scripts in Windows Vista Service Pack 1, in Windows Server 2008, or in Windows XP Service Pack 3: http://support.microsoft.com/?kbid=951978 Update for Windows XP (KB951978): http://www.microsoft.com/downloads/d...DisplayLang=en Update for Windows Vista (KB951978): http://www.microsoft.com/downloads/d...displaylang=en -- Steve A great many people mistake opinions for thoughts. -Herbert V. Prochnow |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Known bug in CStr (Date ()) in WSH 5.7? In microsoft.public.scripting.vbscript message <4877acad$0$7539$9b4e6d93 @newsspool1.arcor-online.net>, Fri, 11 Jul 2008 20:55:41, Alexander Mueller <millerax@xxxxxx> posted: Quote: >Actually you should never rely on an automated date to string >conversion. It's much safer to use date functions such as Day, Month, >DatePart, FormatDatetime etc to build a date string properly formatted. <URL:http://www.merlyn.demon.co.uk/vb-date2.htm#WN> -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME. Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links. Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036) Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036) |
My System Specs![]() |
| | #7 (permalink) |
| | RE: Known bug in CStr (Date ()) in WSH 5.7? Thanks for your comments folks. The issue has now been resolved by hotfix KB951978. Tony "Tony Longson" wrote: Quote: > Hi folks > > I've recently updated my XP laptop to SP3 which has uplifted WSH to v5.7 and > this has introduced a bug regarding the Date () function. When the result is > being converted to a string, it doesn't use the correct local format, but > seems to default to US format instead. Here in the UK the standard format is > DD/MM/YYYY. Here is some example code: > > WScript.Echo Date () > WScript.Echo ““ & Date () > WScript.Echo CStr (Date ()) > > Under 5.6 this produces the correct output: > > Microsoft (R) Windows Script Host Version 5.6 > Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. > > 04/07/2008 > 04/07/2008 > 04/07/2008 > > Under WSH 5.7 the output is: > > Microsoft (R) Windows Script Host Version 5.7 > Copyright (C) Microsoft Corporation. All rights reserved. > > 04/07/2008 > 7/4/2008 > 7/4/2008 > > This happens in both cscript.exe and wscript.exe. > > Is this a known bug? The main problem I have with it is that any WMI queries > using the date either fail or return the wrong data. > > Regards > Tony Longson. > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Known bug in CStr (Date ()) in WSH 5.7? "Dr J R Stockton" <jrs@xxxxxx> wrote in message news:xODJBsRgV8dIFwUM@xxxxxx Quote: > In microsoft.public.scripting.vbscript message <5CB5D3A1-78EA-4EC9-A6DD- Quote: > My general recommendation is never to use conversion code of US origin > for converting to or from strings in non-US format; they are not > trustworthy - as you will recall from their general attitude towards tea > and cricket. ![]() |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Known bug in CStr (Date ()) in WSH 5.7? "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message news:eEKFh4q5IHA.1592@xxxxxx Quote: > "Dr J R Stockton" <jrs@xxxxxx> wrote in message > news:xODJBsRgV8dIFwUM@xxxxxx Quote: >> In microsoft.public.scripting.vbscript message <5CB5D3A1-78EA-4EC9-A6DD- Quote: >> My general recommendation is never to use conversion code of US origin >> for converting to or from strings in non-US format; they are not >> trustworthy - as you will recall from their general attitude towards tea >> and cricket. > Oh, come now. We're always up for a good tea party. ![]() /Al |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Known bug in CStr (Date ()) in WSH 5.7? "Dr J R Stockton" <jrs@xxxxxx> wrote in message news:xODJBsRgV8dIFwUM@xxxxxx Quote: > In microsoft.public.scripting.vbscript message <5CB5D3A1-78EA-4EC9-A6DD- Quote: > My general recommendation is never to use conversion code of US origin > for converting to or from strings in non-US format; they are not > trustworthy - as you will recall from their general attitude towards tea > and cricket. ball itself is more often handled than kicked. The story is that their English ain't so good either. But in your sentence above you seem to have changed the subject from "conversion code of US origin" before the semicolon to the US originators of said code after the " - ", leaving the intended target of the intervening "they" to be just a guess between the two. I forget what that particular grammatical error is called; but I'll bet you remember! ;-) /Al |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Guid and Cstr | VB Script | |||
| Date Taken and Date Modified | Vista music pictures video | |||
| Modified Date used as Date Taken in Photo Gallery and Digital Imag | Vista music pictures video | |||
| Photo date taken vs. file date | Vista music pictures video | |||
| Blank "Date Taken / Date Modified" field in Vista | Vista file management | |||