A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Mtd Question



 
 
Thread Tools Display Modes
  #1  
Old August 31st, 2004, 01:29 PM
CR
external usenet poster
 
Posts: n/a
Default Mtd Question

I have a built queries to give me monthly totals, but the problem is that by
using Month(Now()), I get the current month when it is the 1st day of the
month instead of last month's data. I imagine that I will have the same
problem with the Ytd data. I got around the Daily data problem by using the
Date()-1 function, but I can't seem to find how to use it for month and year.
Any suggestions would be appreciated.

Thank you
Eric
  #2  
Old August 31st, 2004, 01:55 PM
Nikos Yannacopoulos
external usenet poster
 
Posts: n/a
Default

Eric,

Now()-Day(Now())

will always return the last day of the previous month, so:

Month(Now()-Day(Now()))

will always return the month of the previous month.

HTH,
Nikos

"CR" wrote in message
news
I have a built queries to give me monthly totals, but the problem is that

by
using Month(Now()), I get the current month when it is the 1st day of the
month instead of last month's data. I imagine that I will have the same
problem with the Ytd data. I got around the Daily data problem by using

the
Date()-1 function, but I can't seem to find how to use it for month and

year.
Any suggestions would be appreciated.

Thank you
Eric



  #3  
Old August 31st, 2004, 03:35 PM
CR
external usenet poster
 
Posts: n/a
Default

That works great thank you, however, if it isn't the 1st day of the month, I
need the that month's total, and this only gives me last month's total if
today is the 1st day of the month, I it is let's say the 15th of August, I
should see from the 1st to the 14th inclusively, not the month of july. I
know i need an Iff statement, but I'm not sure how to phrase it.

"CR" wrote:

I have a built queries to give me monthly totals, but the problem is that by
using Month(Now()), I get the current month when it is the 1st day of the
month instead of last month's data. I imagine that I will have the same
problem with the Ytd data. I got around the Daily data problem by using the
Date()-1 function, but I can't seem to find how to use it for month and year.
Any suggestions would be appreciated.

Thank you
Eric

  #4  
Old August 31st, 2004, 04:07 PM
SteveS
external usenet poster
 
Posts: n/a
Default

Try these:

For the last day of the month:

=IIF(Day(Date())=1, Day(Date())-1, Day(Date()))


For last month on the 1st of the new month:

=IIF(Day(Date())=1, Month(Date())-1, Month())

For last year on Jan 1st:

=IIF(Month(Date())=1 and Day(Date())=1, Year(Date())-1, Year(Date()))

HTH
Steve
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)



"CR" wrote:

That works great thank you, however, if it isn't the 1st day of the month, I
need the that month's total, and this only gives me last month's total if
today is the 1st day of the month, I it is let's say the 15th of August, I
should see from the 1st to the 14th inclusively, not the month of july. I
know i need an Iff statement, but I'm not sure how to phrase it.

"CR" wrote:

I have a built queries to give me monthly totals, but the problem is that by
using Month(Now()), I get the current month when it is the 1st day of the
month instead of last month's data. I imagine that I will have the same
problem with the Ytd data. I got around the Daily data problem by using the
Date()-1 function, but I can't seem to find how to use it for month and year.
Any suggestions would be appreciated.

Thank you
Eric

  #5  
Old August 31st, 2004, 05:11 PM
Crown Royal
external usenet poster
 
Posts: n/a
Default

Excellent, tyvm guys, I was close, but wasn't putting the (Date) functions in

Thx

"SteveS" wrote:

Try these:

For the last day of the month:

=IIF(Day(Date())=1, Day(Date())-1, Day(Date()))


For last month on the 1st of the new month:

=IIF(Day(Date())=1, Month(Date())-1, Month())

For last year on Jan 1st:

=IIF(Month(Date())=1 and Day(Date())=1, Year(Date())-1, Year(Date()))

HTH
Steve
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)



"CR" wrote:

That works great thank you, however, if it isn't the 1st day of the month, I
need the that month's total, and this only gives me last month's total if
today is the 1st day of the month, I it is let's say the 15th of August, I
should see from the 1st to the 14th inclusively, not the month of july. I
know i need an Iff statement, but I'm not sure how to phrase it.

"CR" wrote:

I have a built queries to give me monthly totals, but the problem is that by
using Month(Now()), I get the current month when it is the 1st day of the
month instead of last month's data. I imagine that I will have the same
problem with the Ytd data. I got around the Daily data problem by using the
Date()-1 function, but I can't seem to find how to use it for month and year.
Any suggestions would be appreciated.

Thank you
Eric

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about Absolute reference formula Maria General Discussion 3 June 23rd, 2004 06:27 PM
Designing a question paper Ken New Users 2 April 28th, 2004 10:13 PM
Question on Array Formula John Worksheet Functions 1 February 21st, 2004 05:40 PM
Ye olde blank cell question.. maybe XLguy Worksheet Functions 3 February 10th, 2004 09:49 PM
Charting in a single cell question... LSMark Charts and Charting 3 January 8th, 2004 03:00 PM


All times are GMT +1. The time now is 08:59 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.