Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting dates to Text

Status
Not open for further replies.

IanWaterman

Programmer
Jun 26, 2002
3,511
GB
I need to group my report depending on an input from user, I am using the following formula to group.

If {?PRT_PARAM_STR1} = "Client Name" then {@Client_Name} else
If {?PRT_PARAM_STR1} = "Policy No" then {GENPOLICY.POLICY_KEY} else
If {?PRT_PARAM_STR1} = "Effective Date" then totext(date({ACCOUNTTRANSACTION.ACN_EFFECTIVE_DATE})) else
If {?PRT_PARAM_STR1} = "Product" then {GENPLAN.PLN_NAME}

Within the IF..then..else statment I can not mix strings and dates, so I have converted date to text.

Works OK except the date order is now in day order, 01/01/2003, 01/02/2003, 01....., 02/01/2003, 02/02/2003.

Two questions can I modify my grouping formula so that I can retain data type as date for the Effective Date sort,
or

Can I modify totext(date({ACCOUNTTRANSACTION.ACN_EFFECTIVE_DATE})) to yield date in format yyyy/mm/dd

Thank you

Ian
 
In Crystal 8.5, you could use totext(date({ACCOUNTTRANSACTION.ACN_EFFECTIVE_DATE}), "yyyy/MM/dd")

You can also use one field for grouping and another to display for the group.

Madawc Williams
East Anglia, Great Britain
 
totext(date({ACCOUNTTRANSACTION.ACN_EFFECTIVE_DATE}), "yyyy/MM/dd")

******************

I don't understand the need for a date function here...isn't {ACCOUNTTRANSACTION.ACN_EFFECTIVE_DATE} a date field already??

your formula should be of the form show above...you can leave out the "/" though if you want.

totext({ACCOUNTTRANSACTION.ACN_EFFECTIVE_DATE}, "yyyyMMdd")

ALSO

If {?PRT_PARAM_STR1} = "Client Name" then {@Client_Name} else

****************

Try to avoid other formulas in a Grouping formula ... it just slows things down.

If {@Client_Name} is nothing more than contatenating the first and last name just do it....don't use a formula

If {?PRT_PARAM_STR1} = "Client Name" then
{Table.LastName} + {Table.FirstName}
else


Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top