Board index » delphi » DateTime Format - App vs Control Panel

DateTime Format - App vs Control Panel

Hi,

Is it possible to configure the Date and the Time Format of an
application to be independent of the control panel settings?

In my app I use the dd-mm-yyyy format. I have installed this app in a PC
with the d/mm/yyyy format (that was the setting in the Control Panel). I
have noticed that all my date's control have changed to the format of
the Ctrl Panel. I would like to keep the format that I have defined in
my app. Is it possible? How?

Luis,

 

Re:DateTime Format - App vs Control Panel


See ShortDateFormat.
Quote
Luis Leit?o wrote:

> Hi,

> Is it possible to configure the Date and the Time Format of an
> application to be independent of the control panel settings?

> In my app I use the dd-mm-yyyy format. I have installed this app in a PC
> with the d/mm/yyyy format (that was the setting in the Control Panel). I
> have noticed that all my date's control have changed to the format of
> the Ctrl Panel. I would like to keep the format that I have defined in
> my app. Is it possible? How?

> Luis,

Re:DateTime Format - App vs Control Panel


Quote
"Luis Leit?o" wrote:

> Hi,

> Is it possible to configure the Date and the Time Format of an
> application to be independent of the control panel settings?

> In my app I use the dd-mm-yyyy format. I have installed this app in a PC
> with the d/mm/yyyy format (that was the setting in the Control Panel). I
> have noticed that all my date's control have changed to the format of
> the Ctrl Panel. I would like to keep the format that I have defined in
> my app. Is it possible? How?

> Luis,

Use the FormatDateTime() function (see Delphi help) each time you need a
date. You can specify your own format ('dd-mm-yyyy' or so) or use one of the
Windows settings (ShortDateFormat, LongDateFormat)

Another options would be to change the ShortDateFormat / LongDateFormat
settings at the startup of your program. Use ShortDateFormat:='dd-mm-yyyy';
The new settings do not affect the dates in other programs.

Sasan.

Re:DateTime Format - App vs Control Panel


 From: tropix [mailto:tro...@OntheNet.com.au]
 Sent: Sexta-feira, 22 de Janeiro de 1999 22:10
 To: Luis Leit?o
 Subject: Re: DateTime Format - App vs Control Panel

 Hi...

 Do this to stop the users settings from overriding yours.

 On each form in your app, write an initialization clause....

 initialization
     ShortDateFormat := 'dd/mm/yyyy';

 ....also, if your using the BDE, you will need to change the BDE
 Administrator format settings. The reason that I use the initialization
 rather than a OnCreate event is that it sometimes does not work
 in OnCreate.
 Since doing it this way, I have not had a problem.

 best wishes
 heidi
 Oz

Hi,

I have tried and it didn't work like I needed but... I have add this code:

Initialization
DateSeparator := '-';
ShortDateFormat := 'dd-mm-yyyy';
end.

I put also this code:

Application.UpdateFormatSettings:=False;

in the main procedure of the application

and it finally worked for some objects... But I am still having the problem
with the DateTimePicker object. It seems that this object "don't care" about
this initializations

Anybody know how to make the DateTimePicker work with my Format Date?

Luis,

Quote
Luis Leit?o wrote:
> Hi,

> Is it possible to configure the Date and the Time Format of an
> application to be independent of the control panel settings?

> In my app I use the dd-mm-yyyy format. I have installed this app in a PC
> with the d/mm/yyyy format (that was the setting in the Control Panel). I
> have noticed that all my date's control have changed to the format of
> the Ctrl Panel. I would like to keep the format that I have defined in
> my app. Is it possible? How?

> Luis,

Re:DateTime Format - App vs Control Panel


Quote
"Luis Leit?o" <lslei...@dei.uc.pt> wrote:
>Is it possible to configure the Date and the Time Format of an
>application to be independent of the control panel settings?

Yes, but you had better have a darned good reason before doing so.  Users
configure the date settings to their liking for a reason: that's how they
want to view dates.  "Programmer convenience" is NOT a sufficient reason to
override control panel preferences.  Your program should adapt to the
user's preferences, and not vice versa.

For example, if you want to force the format just to allow you to parse the
date in string format, that's wrong-headed.  You should use the standard
library routines to convert the date to a binary form, independent of
representation.
--
- Tim Roberts, t...@probo.com
  Providenza & Boekelheide, Inc.

Re:DateTime Format - App vs Control Panel


Quote
On Tue, 26 Jan 1999 16:55:20 GMT, t...@probo.com (Tim Roberts) wrote:
>For example, if you want to force the format just to allow you to parse the
>date in string format, that's wrong-headed.  You should use the standard
>library routines to convert the date to a binary form, independent of
>representation.

I've been trying to parsing the date in a TQuery statement. Do you
have any suggestion how to do that ?

For some database engine (Oracle, for instance), even the
ShortDateFormat won't work because Delphi doesn't have the date format
needed on some Oracle configurations (ex. 15-DEC-98, with the Month in
uppercase).

Thanks in advance!

                Josir Gomes
                Rio - Brazil

Re:DateTime Format - App vs Control Panel


With ORACLE (and probably others), you can specify in your SQL what you want
the date to look like i.e:

select to_char(MDATE, 'MM/DD/YYYY') as MDATE from MY_TABLE

Quote
Josir Gomes wrote in message <36b99654.2949...@cnews.newsguy.com>...
>On Tue, 26 Jan 1999 16:55:20 GMT, t...@probo.com (Tim Roberts) wrote:

>>For example, if you want to force the format just to allow you to parse
the
>>date in string format, that's wrong-headed.  You should use the standard
>>library routines to convert the date to a binary form, independent of
>>representation.

>I've been trying to parsing the date in a TQuery statement. Do you
>have any suggestion how to do that ?

>For some database engine (Oracle, for instance), even the
>ShortDateFormat won't work because Delphi doesn't have the date format
>needed on some Oracle configurations (ex. 15-DEC-98, with the Month in
>uppercase).

>Thanks in advance!

> Josir Gomes
> Rio - Brazil

Other Threads