Print Page | Close Window

Convert Number to Date

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=11249
Printed Date: 02 May 2024 at 2:05pm


Topic: Convert Number to Date
Posted By: vzirock
Subject: Convert Number to Date
Date Posted: 28 Sep 2010 at 5:49am
I am trying to convert a number field (integer) to a date field so I can sort on the date.  In the original database it is a date entry but when I bring it to crystal for some reason it is a number field (such as 20,100,101 for Jan 1 2010.  I can't figure out the formula to convert this...please help!



Replies:
Posted By: DBlank
Date Posted: 28 Sep 2010 at 6:27am

try:

date(mid(totext( mailto:%7b@date%7d,0,%29,5,2%29+/ - {datefield},0,''),5,2)+'/' + right(totext( mailto:%7b@date%7d,0,%29,2 - {datefield},0,''),2 ) + '/'+ left(totext( mailto:%7b@date%7d,0,%29,4 - {datefield},0,''),4 ))


Posted By: vzirock
Date Posted: 28 Sep 2010 at 7:11am
which formula spot do I put this in?  the record select formula?


Posted By: DBlank
Date Posted: 28 Sep 2010 at 7:23am

in the field explorer as a new formula field

then you can place the formula on the report canvas


Posted By: vzirock
Date Posted: 28 Sep 2010 at 7:34am
error message that says "the result of selection formula must be a boolean"
 
date(mid(totext({CTCITE.cit_viol_date},0,''),5,2)+'/'+ right(totext({CTCITE.cit_viol_date},0,''),2) + '/' + left(totext({CTCITE.cit_viol_date},0,''),4))


Posted By: vzirock
Date Posted: 28 Sep 2010 at 7:36am
oh, ok. that works.  Thanks!Big%20smile



Print Page | Close Window