Print Page | Close Window

"ToText" with dates

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21271
Printed Date: 02 May 2024 at 5:20am


Topic: "ToText" with dates
Posted By: bremen
Subject: "ToText" with dates
Date Posted: 13 Jan 2015 at 4:42am
I am trying to display a based on some arithmetic. The formula I am using is this


if {Table.Field} = "A"
then
"See Notes"
else
if
{Table.Field} = "B"
then
totext(({Table.DateTime} +2)-today, "dd-MMM-yyyy")
else if
{Table.Field} = "C"
then
totext(({Table.DateTime} +9)-today, "dd-MMM-yyyy")
else if
{Table.Field} = "D"
then
totext(({Table.DateTime} +119)-today, dd-MMM-yyyy")


When I create the formula I am told there are no errors.
When I add the formula to the report and refresh I get an error saying

"Bad Number Format String"

My end result would be to show a date something expires based on the math.



Replies:
Posted By: DBlank
Date Posted: 13 Jan 2015 at 6:00am
({Table.DateTime} +2)-today
will return a number
what is the 'math' you are trying to accomplish?


Posted By: bremen
Date Posted: 13 Jan 2015 at 6:24am
So yes the formula you provided will return a number, but not a date. I need a calendar date. Because of the one special case where the output of the formula will be a text string is throwing off the whole works


Posted By: DBlank
Date Posted: 13 Jan 2015 at 6:36am
but was is the logic for the date?
I don't know what table.date+2 - today is suposed to equate to
table.date+2 is straight forward but the "-today" does not make any sense to me


Posted By: bremen
Date Posted: 13 Jan 2015 at 7:15am
It is for a count down. It displays a "Days Remaining" Number. The formula to produce the number is working fine. I need a separate formula to produce a calendar date.


Posted By: DBlank
Date Posted: 13 Jan 2015 at 7:27am
then format it as a number instead of a date
totext(({Table.DateTime} +2)-today, 0",")



Print Page | Close Window