Thursday, November 1, 2012

Crystal Reports : Calculating Age

One of the many things you will want to do with a bona-fide date field is calculate age.
Crystal makes it easy for us here; as long as we're comparing two date type fields, we can perform simple math.
Let us suppose that the date field in question is {CONTACTS.SOURCEDATE}, which represents when a particular prospect was imported into our database.

1. We can see how many records were imported in the last seven days

{CONTACTS.SOURCEDATE} <= CurrentDate() - 7

2. Or how "old" any particular record is, expressed in days

CurrentDate() - {CONTACTS.SOURCEDATE}

3. To calculate the age in years, we must use the Crystal DateDiff function:

DateDiff("yyyy", {CONTACTS.SOURCEDATE}, CurrentDate())

The "yyyy" specifies we want the answer in years; "m" and "d" are also options (months and days, correspondingly)

7 comments:

Patricia Pabustan said...

I am very happy to know about this site. Thanks for sharing...........


Crystal Custom

Dhiman Sarkar said...

Awesome stylish. It is very nice to me. I want to get it . How?

Crystal Custom

jannati jahan said...

I love this blog.

Crystal Custom

jannati jahan said...

There's nothing like doing assignments and writing lots of code. C# is the most important emerging language.

http://www.dotnetobject.com/

amar jan said...

Once the command has been created, you can store it in the BusinessObjects Enterprise Repository so it can be shared between many users.

Crystal Custom

Nomita Biswas said...

Everything is made of energy. Our bodies are made of energy and filled with energy. Energy is constantly flowing through us.

Crystal Custom

Dharmendro Bhuyan said...

We offer many different styles of custom imprinted sunglasses so that everyone is satisfied.

Customized sunglasses