Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date Conversion Post Reply Post New Topic
Author Message
katich
Newbie
Newbie


Joined: 25 Jun 2010
Location: United States
Online Status: Offline
Posts: 9
Quote katich Replybullet Topic: Date Conversion
     Posted: 01 Sep 2010 at 7:24am
Hello,
 
I'm trying to create a formula in Crytal XI to do a couple things. 
 
I have a date of 07/31/2010 which i want to find the the number of days in the month 2 months prior to this date.  What is the best way to accomplish this?

Thank you,

Frank
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Sep 2010 at 7:41am
may I ask what is the purpose for that number, as there may be a different approach?
IP IP Logged
katich
Newbie
Newbie


Joined: 25 Jun 2010
Location: United States
Online Status: Offline
Posts: 9
Quote katich Replybullet Posted: 01 Sep 2010 at 7:53am

Oh, of course.  Once i'm able to get this number, i will then divide by another field which already has a number.  For example, i have a field that returns the number 2,859 for the month of May.  Since i'm at month end 7/31/10, i want a formula that will give me the number of days in May so I can divide that by the 2,859.  I'll eventually due the same for June, Year to Date and Last year to date

                                          Income Statement
                                         Month ending 7/31/10
May                     June                  July                YTD           LYTD
 
 
Each month and YTD and LYTD will have a number similar to the 2,859 that i will want to divide the number of days of each month into.  So next month when 8/31/10 is upon me, the may will switch to June, June to July and etc. 
Make sense?
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Sep 2010 at 8:13am
so you need to grab total number of days per month for the last 3 months rolling from today's date?
lastmonth
day(dateserial(year(currentdate),month(currentdate),1-1))
previous month
day(dateserial(year(currentdate),month(currentdate)-1,1-1))
2 months ago
day(dateserial(year(currentdate),month(currentdate)-2,1-1))


Edited by DBlank - 01 Sep 2010 at 8:14am
IP IP Logged
katich
Newbie
Newbie


Joined: 25 Jun 2010
Location: United States
Online Status: Offline
Posts: 9
Quote katich Replybullet Posted: 01 Sep 2010 at 9:25am
That worked Great!  Thank you
 
Now i have one last question.  If i want the number of days for YTD and LYTD, would i need to go in every month and change the formula or is there another way of doing this?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Sep 2010 at 10:56am
do you mean you want to know the # of days within the year at the end of each of the months?
datepart('y',dateserial(year(currentdate),month(currentdate)-3,1-1))
IP IP Logged
katich
Newbie
Newbie


Joined: 25 Jun 2010
Location: United States
Online Status: Offline
Posts: 9
Quote katich Replybullet Posted: 07 Sep 2010 at 4:14am
Yes, i wanted to know the number of days in my Year to date column after a particular month.  I think i figured it out though by changing a couple numbers in the formula you gave me.  Thank you
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum