Monday, March 9, 2015

Crystal Reports : Dates and the Math of Age

Yes, this old chestnut never stops being useful;

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


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)

Note: In order for Date Math to work correctly, all evaluated fields MUST be Date Types. Otherwise they must first be converted to Date Types using a Crystal Function like CDATE(). 

1 comment:

Anonymous said...

Bamboo bed sheets chemical from a mechanics through the manages create your handbag highly effective and don't quickly shattered. chanel replica Gucci company logo would be the classic Gucci a symbol manifestation similar to increase H company logo. fake chanel The regular hues are generally dazzling red-colored along with eco-friendly mix. chanel replica As part of your years that will cow leather-based along with sheepskin are generally consequently normal which in turn makes it possible for the idea to never satisfy the requirements from all of the girls, rare chemical are generally consequently renowned currently. chanel replica sale Crocodile leather-based involving Gucci Seventies Channel Boston ma Handbag Beige Ebony Pied-de-poule Textile create these kinds of totes consequently classiness. chanel replica sale abigialfu yaplog web site This specific handbag are actually consequently renowned one of several Oriental young ladies for two main confined format throughout green bring in each of the girls.