BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: ...not a valid date and time.

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Tracy Stevens
Guest





PostPosted: Tue Jul 15, 2003 3:10 pm    Post subject: Re: ...not a valid date and time. Reply with quote




I'm not sure I understand what you're asking. Yes, I have tried removing
the leading zero from the string before attempting to convert it, but that
failed also.

Are you referring to something else?


"Liz Albin" <lizalbin (AT) yahooNotThis (DOT) com> wrote

Quote:
On Tue, 15 Jul 2003 09:53:31 -0500, Tracy Stevens wrote:

I get the message "'07/15/2003' is not a valid date and time."

Have you tried with 7/1/2003?

I ask because it's possible your system date format is not what you
believe it to be.
--
liz



Back to top
JD
Guest





PostPosted: Tue Jul 15, 2003 3:21 pm    Post subject: Re: ...not a valid date and time. Reply with quote




"Tracy Stevens" <eat (AT) joes (DOT) com> wrote:
Quote:
[...]
AnsiString temp = date_list->Strings[curr_index];
TDateTime new_dt = StrToDateTime(temp);

I get the message "'07/15/2003' is not a valid date and time."

When I used:

String tmp = "07/15/2003";
TDateTime dt = StrToDateTime( tmp );

It executed without an error.

Has your date seperator changed?

~ JD


Back to top
Antonio Felix
Guest





PostPosted: Tue Jul 15, 2003 4:02 pm    Post subject: Re: ...not a valid date and time. Reply with quote




"Tracy Stevens" <eat (AT) joes (DOT) com> wrote:
Quote:

It used to work fine for me, too.
Where could I see if the date separator changed?


Check the Windows Date/Time Settings in Control Panel | Regional Settings. See if they match your expected settings

Other way is to force the Application settings by using the
global variables 'DateSeparator'...
Look for DateSeparator on the BCB Help System.

HTH
Antonio


Back to top
Tracy Stevens
Guest





PostPosted: Tue Jul 15, 2003 4:12 pm    Post subject: Re: ...not a valid date and time. Reply with quote


My Windows DateTime settings are set correctly as M/d/yyyy with a date
separator of '/'.

My TDateTimePicker works if the DateTime entered is '27/1/03' but not if it
is '27/1/2003' nor '7/15/03'.
So, apparently it is expecting the input to be in the form of dd/mm/yy.

Where do I change this to what I want?


"Tracy Stevens" <eat (AT) joes (DOT) com> wrote

Quote:
I have been using this same line of code in an application without any
problem. However, it started failing recently and I can't determine why.

In a TStringList I store several date values of the form "07/15/2003".

AnsiString temp = date_list->Strings[curr_index];
TDateTime new_dt = StrToDateTime(temp);

I get the message "'07/15/2003' is not a valid date and time."
I am using BCB4.

Thanx,
Tracy





Back to top
JD
Guest





PostPosted: Tue Jul 15, 2003 4:56 pm    Post subject: Re: ...not a valid date and time. Reply with quote


"Tracy Stevens" <eat (AT) joes (DOT) com> wrote:
Quote:
[...] My TDateTimePicker works if the DateTime entered is
'27/1/03' but not if it is '27/1/2003'

Not a problem ... Just use StrToDate() instead.

~ JD


Back to top
Tracy Stevens
Guest





PostPosted: Tue Jul 15, 2003 5:02 pm    Post subject: Re: ...not a valid date and time. Reply with quote

But how would I know which format to change the final product to? I know in
which format I'm storing the strings, but how would I know what the output
should be if it's run on someone else's computer?

And why would this same TDateTimePicker be using European dates all of a
sudden? Corruption?


"JD" <nospam (AT) nospam (DOT) com> wrote

Quote:

"Tracy Stevens" <eat (AT) joes (DOT) com> wrote:
[...] My TDateTimePicker works if the DateTime entered is
'27/1/03' but not if it is '27/1/2003'

Not a problem ... Just use StrToDate() instead.

~ JD




Back to top
Patrick Wong
Guest





PostPosted: Fri Aug 01, 2003 1:40 am    Post subject: Re: ...not a valid date and time. Reply with quote


"Tracy Stevens" <eat (AT) joes (DOT) com> wrote

Quote:
I have been using this same line of code in an application without any
problem. However, it started failing recently and I can't determine why.

In a TStringList I store several date values of the form "07/15/2003".

AnsiString temp = date_list->Strings[curr_index];
TDateTime new_dt = StrToDateTime(temp);

I get the message "'07/15/2003' is not a valid date and time."
I am using BCB4.

Thanx,
Tracy



I had a similar problem days before. I used a TListView to store datetime
values, and when I retrieved the value for manipulation I encounter the same
message. I stepped in the code and traced the exact value stored and found
that the string had a 'n' and 'r' (0x0a and 0x0d respectively) appended.
I called the AnsiString's method TrimRight() to remove the control
characters and got rid of the problem. Take a try... :-)

Patrick.



Back to top
David Erbas-White
Guest





PostPosted: Fri Aug 01, 2003 2:23 am    Post subject: Re: ...not a valid date and time. Reply with quote

Patrick Wong wrote:
Quote:
"Tracy Stevens" <eat (AT) joes (DOT) com> wrote in message
news:3f141520$1 (AT) newsgroups (DOT) borland.com...

I have been using this same line of code in an application without any
problem. However, it started failing recently and I can't determine why.

In a TStringList I store several date values of the form "07/15/2003".

AnsiString temp = date_list->Strings[curr_index];
TDateTime new_dt = StrToDateTime(temp);

I get the message "'07/15/2003' is not a valid date and time."
I am using BCB4.

Thanx,
Tracy




Also, see if you have changed your global settings (i.e., MM/DD/YY vs.
DD/MM/YY). This will give a similar result.

David Erbas-White



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.