Is not a valid date

Is not a valid date

Post by Ronald van » Thu, 18 Sep 2003 21:05:06


Hi,

In an application I write for a W2003 server I have the following line:

DateAppointment:=StrToDate('8-9-2003');
I get: '8-9-2003 is not a valid date error'
The ShortDateFormat is d-M-yyyy so it should work OK, on another server
(W2000) I do not have this problem.
What am I doing wrong?

Greetings,
Ronald van der Pas
 
 
 

Is not a valid date

Post by Dodg » Thu, 18 Sep 2003 23:19:51

On Wed, 17 Sep 2003 14:05:06 +0200, "Ronald van der Pas"
< XXXX@XXXXX.COM > waffled on about something:


Sounds odd... A couple of quick questions...

1) Are you sure DateSeparator = '-' ?

2) Have you tried 'd-m-yyyy' instead (i.e. lowercase strictly to
spec)?

Dodgy
--
MUSHROOMS ARE THE OPIATE OF THE MOOSES

 
 
 

Is not a valid date

Post by Ronald van » Fri, 19 Sep 2003 06:45:52

No, it is executed on the server (it is part of a CGI program).


"Jeremy Collins" < XXXX@XXXXX.COM > schreef in bericht
 
 
 

Is not a valid date

Post by Ronald van » Fri, 19 Sep 2003 06:48:24

Before the call to this I now explicitly do:

DateSeparator:='-';
ShortDateFormat:='d-m-yyyy';

That worked. Very strange.
Thanks all.

"Ronald van der Pas" < XXXX@XXXXX.COM > schreef in bericht
 
 
 

Is not a valid date

Post by erewho » Fri, 19 Sep 2003 21:47:09

On Wed, 17 Sep 2003 21:48:24 GMT, "Ronald van der Pas"



Not really strange, you are explicitly changing the Date settings for
that instance of Delphi

The original Date settings are picked up from the 'Locale' settings of
your client's machine
 
 
 

Is not a valid date

Post by Dr John St » Fri, 19 Sep 2003 22:53:08


ang.pascal.delphi.misc, Ronald van der Pas
< XXXX@XXXXX.COM > posted at Wed, 17 Sep 2003 14:05:06 :-


You are saying that the string '8-9-2003' is actually written in your
Delphi code, with the intent that it be used to set a TDateTime to
represent one of Aug 9 2003 / 8 Sep 2003.

Since that is neither infallible nor necessary, don't do it. Instead,
use

DateAppointment:=EncodeDate(2003, 8, 9); // or 9, 8

which is only one character longer, and infallible, and unambiguous.

NEVER rely on the interpretation of an all-numeric date string, if it
can be avoided, unless you are following ISO-8601.

The EncodeDate Help, in D3, is shoddy; the Example should give 1983 not
83, or the text should refer to special treatment of low first
parameters.

--
?John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ? Web <URL: http://www.yqcomputer.com/ ; - w. FAQish topics, links, acronyms
PAS EXE etc : <URL: http://www.yqcomputer.com/ ; - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.