-
March 28th, 2011, 10:31 AM
#1
Find Begining and end dates of the previous month
Hello,
I am looking for the formula to find the beginning and end of the previous month. If today is march 28 th then I would like to find february's beginning and end date using the system date.
When my crystal report runs it will find invoices, from the previous month.
Post_date between (beginning of February) and {End of February}.
Post_date is formated as MM/DD/YYYY HH:MM:SS am/pm on the db. I want to check against "MM/DD/YYYY"
Thank you,
Pn
Last edited by PNorm; March 28th, 2011 at 01:09 PM.
-
March 28th, 2011, 01:18 PM
#2
Re: Find Begining and end dates of the previous month
To calculate the last day of previous month is :
Code:
Day(DateSerial(Year(CurrentDate), Month(CurrentDate) , 0))
The beginning of the month alway is 1
and use DateValue function, as :
Code:
{Table.Field} >= DateValue(Year(CurrentDate), Month(CurrentDate)-1, 1) And
{Table.Field} <= DateValue(Year(CurrentDate), Month(CurrentDate)-1, Day(DateSerial(Year(CurrentDate), Month(CurrentDate) , 0))
)
JG
-
March 28th, 2011, 01:28 PM
#3
Re: Find Begining and end dates of the previous month
Awesome. Thank you worked like a charm.
-
March 28th, 2011, 08:17 PM
#4
Re: Find Begining and end dates of the previous month
Just be careful when the month is January... need a condition there
JG
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|