Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Month Calculation 1

Status
Not open for further replies.

RabSwinney

Technical User
Aug 21, 2002
25
0
0
FI
Im trying to add and subtract months within text box,s
just say I have a text box with the function =now() with mmmm format giving me January what I want is to be able to do another text box taking one month off but I dont want to use days like =now()-30
 
Have a look at the DateDiff function - it gives lots of information in the help files and will do exactly what you want.

Frank J Hill
FHS Services Ltd.
frank@fhsservices.co.uk
 
How are ya RabSwinney . . . . .

Am I understanding you want the [purple]same Day as Now() but in the previous month?[/purple]

[blue]If not . . . . be a little more specific . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Most forms have queries as data sources. If your form has a query as its data source, then can perform your calculations in that query.

I made a query which displayed this data:

transactionDate x
6/6/2001 May
1/1/2000 December
4/6/2003 March

To calculate x, I used this expression:

x: MonthName(IIf(Month([transactionDate])=1,12,Month([transactionDate])-1))

________________________________________________

You could also do the calculations right on the form. This would be the code for the second text box (the first text box is "text0"):

MonthName(IIf(Month([text0])=1,12,Month([text0])-1))
 
to paraphrase the above:

X: MonthName(Month(DateAdd("m", -1, [TransactionDate])))

Of course, this (as well as OhioSteve's "Calculation") that there IS a real date value behind hte Text box displaying the Month Name.

Then, again, you seem to have rejected the use of these trivial procedures / functions as they are somewhat more complex than the one you aready don't want to use.







MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top