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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FormatDateTime not inserting leading zero

Status
Not open for further replies.

pwesson

Programmer
Apr 10, 2000
95
CA
I have some code that is doing a FormatDateTime function on a TDateTimePicker, but for some reason it will drop the leading zero from the month or day.

sample:
sMonth := FormatDateTime('mm', DateTimePicker1.DateTime);

sMonth should return a two digit month and it does 99% of the time, but that 1% of the time it does not.

Could this be a dll issue? i.e. Another program open that is using a DLL from its own folder and because it is in memory, my app uses it rather than the default in \system32 ??

Paul

Paul Wesson, Programmer/Analyst
 
Hmm
The Link library event seems unlikley, could be a Delphi Bug have you had a look at the Delhi bug list
I assume that you have only tested this on one machine,
it could be a windows problem, a new version of windows e.g. 'XP', might be attemping to set its default format.
your app might catch the interrupt at the point sometimes.
again this sort of thing should be in the Bug list,
You might just have to trap the error and correct it with a bit of string manipulation.
Steve
 
I'm using Delphi 5.0 with latest patches.

I have 100 clients running my app and only one complaining of the problem. That is not to say other clients are not having the same trouble.

I know they are running XP, as am I. I have not been able to duplicate the problem, that is why I suspect it is a DLL issue or conflict.

I'll keep searching...

Paul Wesson, Programmer/Analyst
 
While you are searching, insure the correct result:
Code:
DecodeDate(DateTimePicker1.DateTime, ThisYear, ThisMonth, ThisDay);
sMonth := IntToStr(ThisMonth);
if ThisMonth < 10 then
    sMonth := '0' + sMonth;

Cheers
 
Try setting

ShortDateFormat := 'mm/dd/yyyy';

prior to using the function... see if it fixes the problem.

HTH,
JGS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top