Andiana
Andiana

Reputation: 1952

Foxpro validate string as datetime?

I have a form and a textbox to bind a field from db (datetime type), which allow user to edit, now I want to only allow user enter a valid datetime (dd/mm/yyyy) format string. How can I do that?

Upvotes: 0

Views: 1356

Answers (1)

DRapp
DRapp

Reputation: 48139

If your textbox is bound to a column in the table that is a date/time, it will by default only allow a valid date-time for you, and if invalid will popup a "wait window" error message (typically top-right of screen) with a message "Invalid Date/Time" which you could customize if you needed to... but this validation is built in automatically.

Now, the sample you have of specific datetime format of "dd/mm/yyyy" is based on "SET DATE" setting... There are many, but yours specifically would be

SET DATE DMY

And that could be done anywhere up-front in your application so the entire VFP app in the default data session knows dates should be entered in Day/Month/Year format...

And if you want century included for full 4-digit year, you could do

SET CENTURY ON

Upvotes: 1

Related Questions