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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate # of months

Status
Not open for further replies.

Zonie32

Technical User
Jan 13, 2004
242
US
Using WINXP, Access 2003

How would I write a query formula to show my date Field which is called RG_Exp_Date minus (-) a date of 8/1/2003 to get the # of months between the 2 dates?

I tried #Months:([RG_Exp_Date]-8/1/2003), but it gives me #ERROR# in the query field. Any help? Thanks a lot.
 
DateDiff('m',#2003-01-01#,[RG_Exp_Date])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry for the typo:
DateDiff('m',#2003-08-01#,[RG_Exp_Date])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks a lot all. I forgot about that DateDiff function. PHV, your solution worked out great.
 
Is there a way to add to this formula to show if [State]=FL, then subtract 11/1/2003 from RGExpDate and if it is any other [State] to subtract 8/1/2003?
 
once again.., not sure of syntax..but using IIF() you can do it :)

-DNG
 
i will try...may be PHV will correct me

IIF([state]='FL',DateDiff('m',#2003-11-01#,[RG_Exp_Date]),DateDiff('m',#2003-08-01#,[RG_Exp_Date]) )

is that right PHV??

-DNG
 
DateDiff('m', IIf([State]='FL',#2003-11-01#,#2003-08-01#), [RG_Exp_Date])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
but you always need to be careful using datediff. it returns "interval boundaries", not an arthmatic value. e.g;
Code:
? datediff("y", #12/31/04#, #1/1/05#)
 1 
? datediff("m", #12/31/04#, #1/1/05#)
 1

or, be careful what you ask for, you may get it - even though you wern't careful in hte asking



MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top