Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: What formula to work out difference between dates? Post Reply Post New Topic
Author Message
BadBoyHouse
Newbie
Newbie


Joined: 25 May 2010
Online Status: Offline
Posts: 20
Quote BadBoyHouse Replybullet Topic: What formula to work out difference between dates?
     Posted: 25 May 2010 at 7:23am
I'm running Crystal v12.

We use a date field in our SQL database that we use to store the client's year end date.

As the year end date (date and month) doesn't change for a client, the year end date field in all of our reports is set to just show the DD/MM part. Over the years as new clients are set up we just enter the date and month - the year part is irrelevant although as in all date fields the year is automatically entered.

Doing it this way means that we don't have to adjust the year end year part each year. We just use the DD/MM part.

I need to create a formula that works out the number of days there have been (i.e. the difference) from the current date to the year end date. It MUST EXCLUDE the year however.


For example:

Year End Date = 30/04/03
Current Date = 25/05/10
Days Difference (EXCLUDING year) = 25 <--- this is what I need
Days Difference (including year) = 2582

Year End Date = 31/03/09
Current Date = 25/05/09
Days Difference (EXCLUDING year) = 55 <--- this is what I need
Days Difference (including year) = 420

If you include the year part then working out day difference is simply a case of creating a formula that subtracts the year end date from the current date (CurrentDate - {tblClient.YearEnd}.

HOWEVER I need to exclude the year part.

Can anyone tell me the formula or best way to do this?

Thanks in advance.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 May 2010 at 7:55am
maybe:
datediff('d',date(year(currentyear),month(datefield),day(datefield)),currentdate)
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