Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Date Format Post Reply Post New Topic
Author Message
Kevinma
Newbie
Newbie


Joined: 14 May 2007
Online Status: Offline
Posts: 6
Quote Kevinma Replybullet Topic: Date Format
    Posted: 20 Nov 2007 at 6:34pm
I have a parameter whioch select Month, Week or Day.  I want to convert a date field dependent on the parameter selection.
ie
if month the date format is Nov 07
if Week then the first day of the week is shown ie 19 Nov 07
id day is selected then just the date is shown ie 21 Nov 07
 
the formula is
 
if {?Chart}='Month' then ******
else if {?Chart}='Week' then ******
else date({Incident_Date})
 
what is the formula for '******'?
It needs to return a date format as it is then sorted in date order.
thanks in anticipation
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 21 Nov 2007 at 5:40am
There are two basic ways of doing this.  As a note, both ways actually convert the date into a string value.  As long as you just use this for display, and don't try to do anything like group on the value, it shouldn't have any effect.

The simplest function is just to use CStr.  If you look it up in the help file, it will tell you about converting date (or datetime) values to strings.  It will also guide you to a page with all the various options for how to format your dates.

The more complex, but more flexible, method is to use the DatePart function to separate your date into its component parts, and build whatever string you choose.  Check out the DatePart function in help.  Also check out the Year, Month, and Day functions, as they are shortcuts of common DatePart functions.


IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.