?
Solved

how can i validate a date field

Posted on 2010-11-07
6
Medium Priority
?
691 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:luciliacoelho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Expert Comment

by:mikegagnon
ID: 34081113
set the format of the textbox to D?
0
 
LVL 2

Expert Comment

by:GreatSolutions
ID: 34081553
if those fields are textboxes, why not setting their values to {} if it's for data entry?
0
 
LVL 27

Accepted Solution

by:
CaptainCyril earned 2000 total points
ID: 34081966
IF CTOD(cDate) = {}
    WAIT WINDOW "Date is invalid"
ELSE
    WAIT WINDOW "Date is valid"
ENDIF
0
How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

 

Expert Comment

by:IQuittner
ID: 34083688
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.
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34084208
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) <> {}
0
 

Author Comment

by:luciliacoelho
ID: 34085482

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?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question