How to "Trunc" dates in Crystal reports

Hello Fellow members!

First time posting and relatively new in Crystal Reports Xi (and 10) and SQL…

I’ve run into a problem…

I have the following entered in the formula editor…

If {?DateType} = ‘Order Date’
then Date({Command.ORDER_DATE})
else Date({Command.ORDER_STATUS_UPDATED})

In the parameter field, during testing, when I choose Jul 1, 2013, the report runs as intended. But once I start changing to some other random dates, for some, it would act as if it doesn’t recognize the date and report on ALL DATES going back to 2009 (ie. from day 1!)…

This occurs when I have the SQL command without the “TRUNC” function… so for my learning purposes, how do I use the equivalent in the formula editor? I thought the “DATE” function is the equivalent?

Thanks in advance for your responses everyone! Looking forward to it! Please keep in mind I’m a rookie still so …


cestmoi (BOB member since 2013-07-02)

I’m definitely missing a part of the issue.

The formula you posted only determines which date field to look at based on the prompt. I don’t see where it’s asking for a date entry.

Are the Order_Date and Order_Status_Updated fields actual Date or DateTime fields? Do you have another parameter prompting for a date?
When you run the report are you only expecting records for one field or the other and for a specified date?

If your ‘date’ fields are actually string fields, convert them to dates before using them in the selection criteria.

Just not enough info to really understand the issue.


MizarKey (BOB member since 2009-12-16)

sorry, forgot to get back to say that I’ve solved my own self-made issue:

In my sql statement, I had it ORDER BY another_field so when I was looking at the date field, it was ‘out of sequence’ and I thought that the formula using ‘Date’ function didn’t work, when in fact it did after ORDER BY the_date field.

Let this be a lesson to you newbies out there!


cestmoi (BOB member since 2013-07-02)