Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to validate dates? (month and day only)
Message
From
29/12/2000 11:38:00
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00457589
Message ID:
00457807
Views:
31
>Cetin,
>
>>Hi Joe,
>>First case only handles with assumption Feb29 always invalid. I don't have an idea about why it's needed and provided the 'otherwise' portion (where Feb29 might be valid on cases such this day and month is queried for the current year).
>>You're right on error part. I assumed (:) Joe's spinner and combo already limited the days and months choosable.
>
>Your first check was:
>
>isValid=!empty(date(1999,lnMonth,lnDay))
>
>This will handle Feb 29th as well as any other date. For example:
>
>? date(1999,2,29) && returns empty date
>? date(2000,2,29) && returns {02/29/2000}
>
>Basically, provided his spinners make sure the month is between 1 and 12, and the day is between 1 and 31, your simple one-liner is a most elegant solution...
>
>If I am still missing something, or if I misread the original post or yours, let me know! I love date stuff! *smile*
>
>JoeK

Joe,
I think you don't misread but I miswrite :)
date(1999,2,29) would return an empty date but Joe might need it to be treated valid time to time. For example :

'Please enter check date' and 2, 29 picked. For a special case it might mean process all dates in table where day(myDate)=29 and month(myDate)=2 (I see you smiling seeing an example with solution in itself :)
What I mean I simply don't know if Feb29 would always be invalid for Joe or not.
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