Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Format jumps from dd/mm/yyyy to dddd/mm/yy

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
We've encountered an oddity of late in the sense that a new Windows XP machine sometimes throws up an error in regards to the formatting of dates.
We have a MaskEdit component such that entries are made in the format 'dd/mm/yyyy'.
HOWEVER it has been found that sometimes Delphi or Windows will try to read this text in the format 'dddd/mm/yy' - for instance we might get the error "0707/20/03 is not a valid date" (obviously should be being read as "07/07/2003").
This happens on rare occasions and we can't recreate it when debugging on the development machines - it has only been seen on a client machine and causes our user some degree of frustration.
There is nothing special about the dates or what the user is doing - sometimes its OK - sometimes it throws us the problem !!
Has anyone encountered something like this ?
Where can I start looking for a solution to it ?
Thanks in advance
Steve
 
Just a guess..., prolly it depend on the user date format define in windows, maybe when u try to valid your date if the user as define in windows yyyy/mm/dd as date format, delphi will use that to test the date.

jb
 
First, do not use TMaskEdit. It just makes users grumpy.

0707/20/03 really is not a valid date, so maybe your date format is fine.

See if a TEdit is okay, then look at the various date edits available.

Cheers
 
hi,

I think its a different format. It is not jumping from
dd/mm/yyyy to dddd/mm/yy but to yyyy/mm/dd. It represent the years first and the users enters the date as he is used to do and then gets the error.
Probably there is a program who changes the short or longdate format in the windows surronding. So in order to get ride of all the other programs who are changing the dateformat start your program with
ShortDateFormat := 'dd/mm/yyyy';
DateSeparator := '/';
put the sysutils in the uses clause.

The SysUtils unit includes a number of variables that are used by various formatting routines. Values are assigned to these variables to define the formats of numeric and date/time strings. The initial values of these variables are fetched from the system registry using the GetLocaleInfo function in the Win32 API. VCL (non-console) applications automatically update these formatting variables in response to WM_WININICHANGE messages.


so if you inclube above statements you always relay on your settings and not on the most strang settings users use and other programmers you change this at runtime with their programs.

Steph [Bigglasses]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top