"the date two months ago (from today)" ?

G

Guest

Hi all.

I'm trying to create an iif statement that basically says:

If "the date imported" field is greater than "the date two months ago (from
today), then update the field to "new", if not update it to "preorder"

aka

IIf [tablexyz].[date imported] > "the date two months ago (from today)",
"new", "preorder"

The problem is that I don't know the correct way to indicate this value
"the date two months ago (from today)".

Anyone?
Much thanks in advance.
 
D

Douglas J. Steele

DateAdd("m", -2, Date())

or

DateSerial(Year(Date), Month(Date) - 2, Day(Date))

Don't worry: the 2nd formula will work properly in January and Febuary.
 
G

Guest

Got it, thanks much for the quick reply.

Douglas J. Steele said:
DateAdd("m", -2, Date())

or

DateSerial(Year(Date), Month(Date) - 2, Day(Date))

Don't worry: the 2nd formula will work properly in January and Febuary.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Trunks said:
Hi all.

I'm trying to create an iif statement that basically says:

If "the date imported" field is greater than "the date two months ago
(from
today), then update the field to "new", if not update it to "preorder"

aka

IIf [tablexyz].[date imported] > "the date two months ago (from today)",
"new", "preorder"

The problem is that I don't know the correct way to indicate this value
"the date two months ago (from today)".

Anyone?
Much thanks in advance.
 
G

Guest

Hm, will an IIF statement work this way?

IIf(this value is true, then continue on to this next IIf statement)

aka

IIf([tablexyz].[Status]="pre", IIf(([Hazel’s Beloved Products
File].[QtyOnHand]>0,â€newâ€

Douglas J. Steele said:
DateAdd("m", -2, Date())

or

DateSerial(Year(Date), Month(Date) - 2, Day(Date))

Don't worry: the 2nd formula will work properly in January and Febuary.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Trunks said:
Hi all.

I'm trying to create an iif statement that basically says:

If "the date imported" field is greater than "the date two months ago
(from
today), then update the field to "new", if not update it to "preorder"

aka

IIf [tablexyz].[date imported] > "the date two months ago (from today)",
"new", "preorder"

The problem is that I don't know the correct way to indicate this value
"the date two months ago (from today)".

Anyone?
Much thanks in advance.
 
J

John Vinson

Hm, will an IIF statement work this way?

IIf(this value is true, then continue on to this next IIf statement)

aka

IIf([tablexyz].[Status]="pre", IIf(([Hazel’s Beloved Products
File].[QtyOnHand]>0,”new”

The IIF() function (not statement!) returns the value of its second
argument if the first is True, and returns its third if the first is
False.

Any of the three arguments can be an expression or a function call -
and this includes a call to the IIF() function.

This runs the risk of the expression getting too large and/or too hard
to understand, but you can certainly use something like

IIf([Status] = "pre", IIF([QtyOnHand] > 0, "New", "Old"),
IIF(SomeOtherCondition, "X", "Y"))

Do note that special characters such as ’ - or even blanks - in
tablenames are often problematic and should be avoided.

John W. Vinson[MVP]
 

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