# Date field validation?

This topic is 6635 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

All,

I'm puzzled about how to validate a date field, i.e. to check for impossible or incomplete dates. In FP6 I could do this with the "isvalid" calculation. FP7 seems to be more tolerant.

I have 3 numeric fields, Day_n, Month_n and Year_n, and I want to check whether the resulting date is valid. Of course, things like 1/0/2005 or 2/29/2005 should be invalid.

FP7 just returns 12/31/2004 in the first case, 3/1/2005 in the second when I use Date_d = Date(Month_n;Day_n;Year_n). Consequently, IsValid (Date_d) always returns 1. Any ideas how to do a *real* check?

Thanks for any ideas!

Lutz

##### Share on other sites

Let( D1 = Date( Month_n; Day_n; Year_n );

Month(D1) = Month_n and Day(D1) = Day_n and Year(D1) = Year_n )

?

##### Share on other sites

Why not use a real date field for the data entry, then change your other fields to calculations?

Day_n = day(date_enter)

Month_n = Month(date_enter)

Year_n = Year(date_enter)

That way the date enter field would automatically validate a valid date.

...just a thought...

##### Share on other sites

Queue,

cute, this is something that works- actually,

Day_n = Day( Date( Month_n; Day_n; Year_n) )

would be enough in my case, since the day can be -1/+3 days off, at most, within the scope of my problem. Thanks! And still I am puzzled about FP7's lack of a corresponding function...

DykstrL,

the problem is that I have the day, month and year numbers to begin with- it is in the naming convention of scans I want to import into the database. The problem is that the scan names are not tamper-proof, so I just want to make sure that the date extracted from the name evaluates to a valid date.

Thanks for giving me your thoughts on this!

Lutz

##### Share on other sites

This topic is 6635 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account