Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Difference of MonthToDate? Post Reply Post New Topic
Author Message
ultraca
Newbie
Newbie
Avatar

Joined: 31 Mar 2011
Location: United States
Online Status: Offline
Posts: 23
Quote ultraca Replybullet Topic: Difference of MonthToDate?
     Posted: 02 May 2011 at 8:02am
So the MonthToDate function shows the range of the first day of the month to 'today'.

However I need to calculate the number, in days of that range to use in another calculation.

I tried to create a custom formula to calculate the difference between the first day of any month and current date, but I get an error saying that I need to enter in an actual date:
DateDiff ("D",Day (1) ,CurrentDate )
"A date is required here"

I was also thinking if there was a way to convert a range to a numerical value but havent been successful.

What do you all recommend the best way to approach this?
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 02 May 2011 at 8:34am
You could use dateserial to get the first day of the current month:

datediff('d', dateserial(year(currentdate), month(currentdate), 1), currentdate)
|< /\ '][' ( )
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 May 2011 at 4:22am
day(currentdate) gives you the day of the month wich I think is the value you need.
IP IP Logged
ultraca
Newbie
Newbie
Avatar

Joined: 31 Mar 2011
Location: United States
Online Status: Offline
Posts: 23
Quote ultraca Replybullet Posted: 03 May 2011 at 7:28am
frnhtGLI - that was it! Thanks (to you also DBlank)
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