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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems formatting datetime using totext

Status
Not open for further replies.

LMGroup

MIS
Apr 10, 2006
85
CA
I'm using CR Developer 12.2.0.290 to create reports from MS SQL Server. A 3rd party Print MIS system is the interface to the SQL db.

The report I created calculates the number of days between 2 tasks and everything seems to be working wonderfully except for the way it displays the 2nd date (which may or may not be present)

When I run the report in Crystal in the original design I created, the datetime field (converted to text using totext because it prints "na" if the field is empty) displays as m/dd/yy which is exactly what I want. When I run it from the 3rd party software interface, that field appears as d/mm/yyyy hh:mm:ssAM.

I tried modifying the formula to force the format to what I want it to be. I specified "m/dd/yy" in the totext formula. Now, when I run the report from either location (CR or 3rd party), the date appears as 0/dd/yy. Why did the month become a 0 in all instances that it should appear?

Here's the formula I was working with:

Code:
shared stringvar invoice;

if isnull({WinAcctBatch.DatePostRan}) then
     invoice:="na"
else
     invoice:=totext({WinAcctBatch.DatePostRan},"m/dd/yy"); [COLOR=#ff0000](gives me 0/dd/yy no matter where I run it)[/color]
     //invoice:=totext({WinAcctBatch.DatePostRan});         [COLOR=#ff0000](gives me m/dd/yy in CR and the full datetime in 3rd party sw)[/color]

invoice

Thanks in advance for any help!
 
Try something like this:

invoice:=totext(cdate({WinAcctBatch.DatePostRan}));
 
totext({WinAcctBatch.DatePostRan},"M/dd/yy")

For date formatting, case matters.

-LB
 
Thank you. It worked. I didn't know that case mattered with the dates.

L:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top