Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Convert number to date Post Reply Post New Topic
Author Message
sw1085
Newbie
Newbie


Joined: 27 Jun 2012
Online Status: Offline
Posts: 3
Quote sw1085 Replybullet Topic: Convert number to date
    Posted: 27 Jun 2012 at 4:31am
Hi - I have a field in my report which has numbers stored but the numbers represent a month such as 2012006 would be June 2012.
 
The numbers appear on my report as 2,012,006 and I need to format them so that they can appear as 06/2012.
 
Can someone help me with this please?
 
Thanks very much
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Jun 2012 at 5:48am
you can convert it to an actual date field and then use the foprmat properties to show only MM/yyyy
date('01/'+ right(totext({table.date},0,''),2)+'/'+left(totext({table.date},0,''),4))
 
or
 
you can just do a text conversion
right(totext({table.date},0,''),2)+'/'+left(totext({table.date},0,''),4)
IP IP Logged
sw1085
Newbie
Newbie


Joined: 27 Jun 2012
Online Status: Offline
Posts: 3
Quote sw1085 Replybullet Posted: 27 Jun 2012 at 6:33am
Fantastic, thanks very much for that.  Works a treat.
IP IP Logged
curtiscj13
Newbie
Newbie


Joined: 02 Jan 2013
Location: United States
Online Status: Offline
Posts: 7
Quote curtiscj13 Replybullet Posted: 02 Jan 2013 at 3:44am
DBlank,
 
You formulas on numbers to date fields have been a great help. Can you help me clarify this error when I try to create a parameter field using the your above referenced formula- I get a 'bad date format string' error.
 
I need to create a parameter field which allows you to select a ship date for which records to display.
 
Thank you
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Jan 2013 at 3:49am
can you explain what your data set is like (what is the format of the field you are referencing) and what the query you want to do is?
IP IP Logged
curtiscj13
Newbie
Newbie


Joined: 02 Jan 2013
Location: United States
Online Status: Offline
Posts: 7
Quote curtiscj13 Replybullet Posted: 02 Jan 2013 at 4:01am
The data set is dates (from Macola) but Crystal reads it as a number field. Its formatted as ex: 20,130,102.
 
I used the following fomula to convert it to a date field;
 
date(mid(totext({oeordhdr_sql.shipping_dt},0,''),5,2)+'/'+ right(totext({oeordhdr_sql.shipping_dt},0,''),2) + '/'+ left(totext({oeordhdr_sql.shipping_dt},0,''),4))
 
Now Im trying to use this formula field as a parameter to select a date which to display records for. Thats where Im getting the "bad date format string" error.
 
The selection formula is ;
 
{@Ship Date\} = Date (2013, 01, 02)
 
Is this the problem?
 
Appreciate your help-
 
 
IP IP Logged
curtiscj13
Newbie
Newbie


Joined: 02 Jan 2013
Location: United States
Online Status: Offline
Posts: 7
Quote curtiscj13 Replybullet Posted: 02 Jan 2013 at 7:03am
Thanks DBlank, but I think I figured it out.
 
There were some 0/00/00 values which were causing the formula to error out. I fixed it with and If Else statement-
 
Thanks again
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.047 seconds.