Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: cdate function Post Reply Post New Topic
Author Message
foxy
Groupie
Groupie
Avatar

Joined: 12 Jul 2007
Online Status: Offline
Posts: 50
Quote foxy Replybullet Topic: cdate function
    Posted: 03 Sep 2007 at 12:51am
Hi all,
 
I am trying to convert a string field to a date field.
 
The string field at the minute in the format: JUL-06, AUG-06, DEC-06, JUN-07, AUG-07, ... ...
 
This monthly period is the basi sof my grouping, but when I sort the groups it obviously sorts them in alphabetical order because it is a string field.
 
I need to sort them in date order. I dont really want so do it manually using specified order because there will be new periods added constantly.
 
Will this cdate function work to convert this string?
 
CDate ({TABLE.PERIOD})
 
Thanks
IP IP Logged
rnareshk
Newbie
Newbie
Avatar

Joined: 19 Jul 2007
Location: India
Online Status: Offline
Posts: 30
Quote rnareshk Replybullet Posted: 03 Sep 2007 at 2:20am
have you check with the function Date(<string>).
Thank You,
Naresh.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 04 Sep 2007 at 4:10pm
Because your field is not a complete date, I doubt it will work.  You'll have to either reformat the string into a format like "JUL 1, 2006" or break it down into numbers and use the Date function, something like this:
NumberVar Year;
NumberVar Month;
Year = 2000 + toNumber(right({table.Period}, 2));
Switch(
 left({table.Period}, 3) = 'JAN', Month = 1,
 left({table.Period}, 3) = 'FEB', Month = 2,
 left({table.Period}, 3) = 'MAR', Month = 3,
...);
CDate(Year, Month, 1)
 
-Dell
IP IP Logged
foxy
Groupie
Groupie
Avatar

Joined: 12 Jul 2007
Online Status: Offline
Posts: 50
Quote foxy Replybullet Posted: 05 Sep 2007 at 3:05am
Thanks very much for that hilfy. I have put this into my formula now & will be testing it when i next pick up this project.
 
Thanks


Edited by foxy - 05 Sep 2007 at 3:05am
FOXY
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.031 seconds.