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

Crystal formula to find the prior month end date from today

Status
Not open for further replies.

jchewsmith

Technical User
Nov 20, 2006
161
US
What is the easiest way to write a formula to find the prior month end date?

I am trying to create a formula to find a "Fiscal year to date" when I am running the report in the middle of the next month.

So if I am running report on the 7/15 or 7/1, etc., I want the "Fiscal Year To date" to be 6/30

 
Code:
DECLARE @Dt datetime
SET @dt = '20190719'

SELECT DATEADD(dd, -DAY(@dt), @dt)

Borislav Borissov
VFP9 SP2, SQL Server
 
When does your Fiscal Year start and end?
I deal with two of them at my place. One starts 7/1 and ends on 6/30, and another one starts on 10/1 and runs until 9/30
So depending on which FY I deal with, I either add 6 or 3 months to any date, and retrieve a Year from that calculated data. And I have a FY for that date.


---- Andy

There is a great need for a sarcasm font.
 
My fiscal year ends 6/30 but what I am trying to do is just get the month end date for the last full month.

I want my info to be for the Fiscal Year to date for the date ending the last full month.

So if today is May 15, I want data from 7/1 to 4/30
or if today is June 2, I want data from 7/1 to 5/31.

I have a formula for the fiscal year start date, I need a formula for the date of the last day of the month for the previous month.
 
Did you try my example?

Borislav Borissov
VFP9 SP2, SQL Server
 
I am looking for a crystal select formula, this appears to be a sql formula. How can I use this from within Crystal?
 
You've asked your question here, at forum183, you've got the SQL Server answer.
Ask your question in one of the Crystal forums you belong to.


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top