Print Page | Close Window

PrevQuarter Not Working

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22636
Printed Date: 28 Mar 2024 at 1:55pm


Topic: PrevQuarter Not Working
Posted By: BoltzGirl
Subject: PrevQuarter Not Working
Date Posted: 03 Jul 2018 at 5:33am
I have two formulas that are not working that I am trying to pull the previous quarter dates by using a Beg Date and End Date formula:

BEG DATE:
dateVar EndMonth := Date(Year(DataDate),Month(DataDate),01)-1;

If {?Denied Date From} = Date(1800,01,01) Then
(Date(Year(EndMonth),Month(EndMonth),01))
else
if {?Denied Date From} = Date(1850,01,01) then
minimum(lastfullweek)
else
if {?Denied Date From} = Date(1900,01,01) then currentdate -1
else
If {?Denied Date From} = Date(1925,01,01) Then
Switch (Month(EndMonth) in 1 to 3,Date(Year(DataDate)-01,01,01),
Month(EndMonth) in 4 to 6,Date(Year(DataDate),01,01),
Month(EndMonth) in 7 to 9,Date(Year(DataDate),04,01),
Month(EndMonth) in 10 to 12,Date(Year(DataDate),07,01))
Else
{?Denied Date From}

****My end date is working fine****
END DATE:
If {?Denied Date To} = Date(1800,01,01) Then
Date(Year(DataDate),Month(DataDate),01)-1
else
if {?Denied Date To} = Date(1900,01,01) then currentdate - 1
else
if {?Denied Date To} = Date(1850,01,01) then
maximum(lastfullweek) else
If {?Denied Date To} = Date(1925,01,01) Then
Switch (Month(DataDate) in 1 to 3,Date(Year(DataDate),01,01),
Month(DataDate) in 4 to 6,Date(Year(DataDate),03,31),
Month(DataDate) in 7 to 9,Date(Year(DataDate),06,30),
Month(DataDate) in 10 to 12,Date(Year(DataDate),09,30))
Else
{?Denied Date To}

-------------
Always appreciate the help!



Replies:
Posted By: DBlank
Date Posted: 06 Jul 2018 at 6:08am
if you want the start date of the quarter prior to today's date try
dateadd('q',datediff('q',date(1900,1,1),today)-1,date(1900,1,1))


Posted By: BoltzGirl
Date Posted: 06 Jul 2018 at 9:24am
You are a GENIUS!! Thank you so much, it worked like a gem.

-------------
Always appreciate the help!



Print Page | Close Window