Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date formula Post Reply Post New Topic
Author Message
mparish
Newbie
Newbie


Joined: 20 Aug 2008
Location: United States
Online Status: Offline
Posts: 9
Quote mparish Replybullet Topic: Date formula
     Posted: 03 Sep 2008 at 11:55am
On a Date/Time field, how do you single out the day in order to add a suffix. Example: On the 3rd day of September... 
 
If the day = 3 or 23 then 'rd', if the day = 4, 5, 6 7, 8, 9, 24, 25, 26, 27, 28, 29 or 30 then 'th' and so on.
 
Thanks in advance for your help.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 03 Sep 2008 at 1:41pm
Use the Day() function to pull out the day as a number.
 
I have all the Crystal Reports functions documented in Chapter 7 of my ENcyclopedia book. You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
mparish
Newbie
Newbie


Joined: 20 Aug 2008
Location: United States
Online Status: Offline
Posts: 9
Quote mparish Replybullet Posted: 09 Sep 2008 at 5:43am
Is there a simpler way to do this?
 
if Day (DataDate) = 1 then 'st'; if Day (DataDate) = 21 then 'st';  if Day (DataDate) = 31 then 'st';  if Day (DataDate) = 2 then 'nd'; if Day (DataDate) = 22 then 'nd'; if Day (DataDate) = 3 then 'rd';  if Day (DataDate) = 23 then 'rd';  if Day (DataDate) = 4 then 'th'; if Day (DataDate) = 5 then 'th'; if Day (DataDate) = 6 then 'th'; if Day (DataDate) = 7 then 'th';  if Day (DataDate) = 8 then 'th'; if Day (DataDate) = 9 then 'th'; if Day (DataDate) = 10 then 'th'; if Day (DataDate) = 11 then 'th'; if Day (DataDate) = 12 then 'th'; if Day (DataDate) = 13 then 'th'; if Day (DataDate) = 14 then 'th';if Day (DataDate) = 15 then 'th'; if Day (DataDate) = 16 then 'th'; if Day (DataDate) = 17 then 'th'; if Day (DataDate) = 18 then 'th'; if Day (DataDate) = 19 then 'th'; if Day (DataDate) = 20 then 'th'; if Day (DataDate) = 24 then 'th'; if Day (DataDate) = 25 then 'th'; if Day (DataDate) = 26 then 'th'; if Day (DataDate) = 27 then 'th'; if Day (DataDate) = 28 then 'th'; if Day (DataDate) = 29 then 'th'; if Day (DataDate) = 30 then 'th'
IP IP Logged
Savan
Senior Member
Senior Member
Avatar

Joined: 14 Dec 2007
Location: India
Online Status: Offline
Posts: 162
Quote Savan Replybullet Posted: 10 Sep 2008 at 11:31pm
you can u do in this way also
 
if (day(datadate) in 1,21,31) then
   'st'
else if (day(datadate) in 2,22) then
   'nd'
else if (day(datadate) in 3,23) then
   'rd'
else
   'th'
Thanks
Savan
IP IP Logged
mparish
Newbie
Newbie


Joined: 20 Aug 2008
Location: United States
Online Status: Offline
Posts: 9
Quote mparish Replybullet Posted: 12 Sep 2008 at 6:11am

Great. Thank you soo much.Clap

IP IP Logged
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