Field Data Validation: Date Range

S

Stuart

Hi All,

I've been trying to figure out the syntax to stick in a Validation Rule for
a date field. The hardcoded dates work ( >= #01/01/2005# and <= #01/31/2005#
), but I need a floating 30 day buffer. Like ">= date and <= date+30".

I've been trying different ways for an hour now, and I know it can't be as
difficult as I'm making it.

Thanks for any help!
 
J

John Vinson

Hi All,

I've been trying to figure out the syntax to stick in a Validation Rule for
a date field. The hardcoded dates work ( >= #01/01/2005# and <= #01/31/2005#
), but I need a floating 30 day buffer. Like ">= date and <= date+30".

I've been trying different ways for an hour now, and I know it can't be as
difficult as I'm making it.

Thanks for any help!

Try

BETWEEN Date() AND DateAdd("d", 30, Date())

or
= Date() AND <= Date() + 30

I think the parentheses are necessary or Access will think you're
comparing to a text string "date".

John W. Vinson[MVP]
 
T

Tim Ferguson

I think the parentheses are necessary or Access will think you're
comparing to a text string "date".

This works for me. One thing strikes me, though: what will Access do when
the clock ticks over and the record becomes invalid without being updated?

I just have a feeling that this rule should be implemented as either a
constraint on a data-entry control (rather than a table field), or else as
a query.

Just a thought


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top