Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Format string date in Crystal Report! Post Reply Post New Topic
Author Message
atp2K3
Newbie
Newbie


Joined: 29 Dec 2011
Online Status: Offline
Posts: 10
Quote atp2K3 Replybullet Topic: Format string date in Crystal Report!
     Posted: 07 May 2012 at 5:51am
Hello all,
 
I displayed the date string such '07/20/2012' from an ASP.NET to Crystal Report. How do I get the substring for display YEAR, MO, DAY as the following format:
 
YEAR: 12
MO: 07
DAY: 20
 
Thanks in advance.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 07 May 2012 at 8:05am
I am not sure about ASP.NET.  But three formulas in Crystal would work.

For the year
"YEAR: "+Right({date_string},2)
For the month
"MO: "+Left({date_string},2)
For the day
"DAY: "+Mid({date_string},4,2)
IP IP Logged
atp2K3
Newbie
Newbie


Joined: 29 Dec 2011
Online Status: Offline
Posts: 10
Quote atp2K3 Replybullet Posted: 07 May 2012 at 10:34am

Thanks for your help. If I used your above formula for the date string such '1/7/2011'  or '1/24/2011' ?  The result is displayed: 

MO: 1/
DD:7/
 
Here is a formula that I resolve in case of having one digit or two digits on day as following:  
 
IF (Mid({strdate},3,1) = "/") And (Mid({strdate},5,1) = "/") Then
"DAY: "+Mid({strdate},4,1)
ELSE IF (Mid({?FromDate_RecVal},2,1) = "/") And (Mid({strdate},4,1) = "/") Then
"DAY: "+Mid({strdate},3,1)
ELSE "DAY: "+Mid({strdate},4,2)
 
Similarly, create another formula for MO.


Edited by atp2K3 - 08 May 2012 at 5:48am
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 16 May 2012 at 11:54am
I made the assumed since you showed the month and day as a two digit number in the string, they would would all follow the same format.  I glad you found a solution.
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