Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date Validation
Message
From
17/02/2007 10:34:56
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
17/02/2007 10:19:22
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01196812
Message ID:
01196815
Views:
9
>Is there any way to test if a string will evaluate to a valid date without parsing the string? I tried something like TYPE(CTOD(lcMyString)) and other variations on this theme but nothing seems to work. The empty string (" / / ") must be accepted as a valid date also.
>
>I can't find anything that will work though it seems that there should be some way to get VFP to tell you if a string will be a valid date, but I can't find anything.
>
>I tried the following but it does not work:
> lcString = "abc"
> ldTest = CTOD(lcString)
>because VFP returns {//} which is not acceptable, since the input may be an empty date, but input of an empty date is acceptable so there would be no way to distinguish between input of a valid empty date or an invalid date.
>
>Thanks.

Would this do?
empty(chrtran(m.lcDate,"/","")) or !empty(ctod(m.lcDate))
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform