Print Page | Close Window

Truncate/Clipping a datetime field

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=4414
Printed Date: 18 Apr 2024 at 8:37pm


Topic: Truncate/Clipping a datetime field
Posted By: KopiteJay
Subject: Truncate/Clipping a datetime field
Date Posted: 01 Oct 2008 at 2:49am
Hello,

Firstly, I have a date/time field coming over from sql which outputs something similar to the following:

26/09/2008 00:00:00

I am using this field within a formula that involves some text, and this date/time field. e.g.

'Your next appointment is on ' & {event.date} & '. Please call us ............ etc etc

I would like to chop off the time section to just leave the date. I keep finding how to do it if it were a string but not with this date/time field.

Secondly, is it possible within a formula to force a carriage return so text continues the next line down? I have a few lines of text with some fields within them. Certain parts I want to appear on the next line.

Many thanks in advance. As someone new to Crystal I am very grateful for any help.

Cheers,

Jason



Replies:
Posted By: JohnT
Date Posted: 01 Oct 2008 at 7:43am
The Totext function can be used to convert a date to a string.  Look at the help file for Totext to see how it works.  You can make another formula field called displaydate (or whatever)  and use
 
Totext ({event.date},"MMM d, yyyy")
 
Then make your string say
 
'Your next appointment is on ' & mailto:%7b@displaydate - {@displaydate } & '. Please call us ............ etc etc
 
If you are not sure if the date field is really a date, you might want to first use the ISDATE function.  That returns a boolean to tell you if the date field is a valid date. 
 
I don't know about forcing a carriage return.
 
Good luck.


Posted By: KopiteJay
Date Posted: 02 Oct 2008 at 3:34am
Thankyou very much for that. Got it working with what you said.

Cheers.



Print Page | Close Window