Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Convert Number to Date format Post Reply Post New Topic
<< Prev Page  of 2
Author Message
Norton
Newbie
Newbie
Avatar

Joined: 09 Nov 2010
Location: United States
Online Status: Offline
Posts: 3
Quote Norton Replybullet Posted: 09 Nov 2010 at 6:14am
This formula works perfect with one exception for my situation.   When used where there are nulls, it fails.   I'm trying to convert a Number to date "20101108".

The report refreshes, however once I try to page through it or export... it pulls up the Formula Editor and states "Bad date format string". 

date(left(totext({ORDMST.OMRDAT},0,""),4)+"," + mid(totext({ORDMST.OMRDAT},0,""),5,2) +"," + right(totext({ORDMST.OMRDAT},0,""),2))

I'm looking for some help on how to handle null (blank)
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Nov 2010 at 6:17am
what date do you want to display if it is null?
IP IP Logged
Norton
Newbie
Newbie
Avatar

Joined: 09 Nov 2010
Location: United States
Online Status: Offline
Posts: 3
Quote Norton Replybullet Posted: 09 Nov 2010 at 6:20am
Thanks for the quick reply, thanks.

Simple answer [blank or 'na' ]would be fine. 

Current date would work as well.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Nov 2010 at 6:24am
if isnull({ORDMST.OMRDAT}) then date(1900,1,1) else
date(left(totext({ORDMST.OMRDAT},0,""),4)+"," + mid(totext({ORDMST.OMRDAT},0,""),5,2) +"," + right(totext({ORDMST.OMRDAT},0,""),2))
 
conditionally suppress the field as
currentfieldvalue = date(1900,1,1)
IP IP Logged
Norton
Newbie
Newbie
Avatar

Joined: 09 Nov 2010
Location: United States
Online Status: Offline
Posts: 3
Quote Norton Replybullet Posted: 09 Nov 2010 at 6:42am
returns "Bad date format string" error.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Nov 2010 at 7:15am
what is your raw data type and a few sample rows?

Edited by DBlank - 09 Nov 2010 at 7:15am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Nov 2010 at 7:20am
I see it is numeric but you just want a string of 'YYYYMMDD'?
 
if isnull({ORDMST.OMRDAT}) or {ORDMST.OMRDAT}=0 then ""
else totext({ORDMST.OMRDAT},0,"")
IP IP Logged
<< Prev Page  of 2
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.016 seconds.