iif Date probelm

Sharon Hague

Registered User.
Local time
Today, 04:13
Joined
Jul 10, 2003
Messages
138
Hi All

I am having trouble with an iif function in a form I have created.

I have a field called Date and I have created a label called Mth.

I want the Mth field to return a value 1 if the date is in month 1 or 2 etc based on the date that is entered in the date field.

Just to test whether it works my control source for my Mth label is

=IIf([Date] Between 1/1/3 And 31/1/3,"1","")

When I view the form "" is returned on all entries including the entries with January dates.

Can anybody help?
 
For 1 NEVER EVER use date as a field Date() is a function that returns todays date which just might be your problem.

To get the month from a date use Month(YourDate)

Enclose dates by #:IIf([Date] Between #1/1/3# And #31/1/3#,"1","")

I hope all that put together will help you along.

Regards
 
Namliam

Thanks this has worked.

I tried using the # but I used it in between the day, month, year i.e #01#01#03.

Didn't think of placing the # at the beginning and the end.

Cheers.
 

Users who are viewing this thread

Back
Top Bottom