Avatar of luciliacoelho
luciliacoelhoFlag for Portugal asked on

how can i validate a date field

I have fields that are a char type, but contents a date in format like 08/11/2010. how can i validate the entry for a valid date?
thanks
FoxPro

Avatar of undefined
Last Comment
luciliacoelho

8/22/2022 - Mon
mikegagnon

set the format of the textbox to D?
GreatSolutions

if those fields are textboxes, why not setting their values to {} if it's for data entry?
ASKER CERTIFIED SOLUTION
Cyril Joudieh

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
IQuittner

I agree with Mike that is the easiest solution.  You cannot depend on taking CTOD of a variable because when you check it with the TYPE command it returns date to any value that isn't a date i.e., 01/32/2010... so if you cannot use Mike's suggestion you will not only have to convert it to a date but also check the values in each field MM/DD/YYYY to ensure they are valid for your application.  I have never used CaptainCyril's suggestion and I tested it with an invalid date and it too said it was a date field.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Cyril Joudieh

My suggestion is a validation. It takes the value of a string date and it will it say if it's valid or not and it also depends on your SET DATE.


? isValidDate(table.field)

.T. means it is valid
.F. means it is not

FUNCTION isValidDate
LPARAMETERS cDate
RETURN CTOD(cDate) <> {}
ASKER
luciliacoelho


CaptainCyril's suggestion solvs the problem.
Ii try to put property format D, mikegagnon suggestion and  the field accept data like: 33/02/2010. how can i do this property format results?