Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Partial Date Post Reply Post New Topic
Page  of 2 Next >>
Author Message
tucker2m
Newbie
Newbie


Joined: 04 Aug 2011
Location: United States
Online Status: Offline
Posts: 15
Quote tucker2m Replybullet Topic: Partial Date
    Posted: 12 Nov 2012 at 8:37am
I have a date field that is pulling from my database as "MM/DD/YYYY".  I have converted the date field to a text date range and have no problems with the dates appearing except when the day field is not populated.  So in the database, it may appear as "11//2012".  I have tried conditional formatting to no avail.  I am trying to figure out a custom style in the Format Editor to see if the day is blank/null to replace the day with the text "TBD" but only partially works.  I have tried conditional formatting, but does not work since I have already converted the date to text.
 
I tried the following:
If Day({eloans_csv.InfVenueStartDate0}) < 1 Then
     "TBD"
Else
     ""
But get the error that a date is required in the field.  I also tried doing string if the day is null, then added the text, but that would not work.   Anyone else encounter such issues with dates?  Thanks.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 12 Nov 2012 at 10:57am
Try something like this:
 
If Instr({eloans_csv.InfVenueStartDate0}, '\\') > 0 then
  "TBD"
else
  {eloans_csv.InfVenueStartDate0}
 
-Dell
IP IP Logged
tucker2m
Newbie
Newbie


Joined: 04 Aug 2011
Location: United States
Online Status: Offline
Posts: 15
Quote tucker2m Replybullet Posted: 13 Nov 2012 at 5:23am
Hi Dell,

thanks, I tried that but I suspect I am trying this in the wrong place. I have the dates in a subreport.  I then added the dates to a text box and changed the format of the dates from YYYY/DD/MM to "January 1, 2012" format.  The dates are linked via two keys in the subreport in order to link (the dates correctly to the venue (see below).


When I then add run the report, everything is linked properly and all dates appear correctly except if the date appears as "2013-05-" due to a partial date being entered in the database (instead of appearing as 2013/05/20".  If the later is the date that is pulled from the database, no issues.  If it is the former, then the date does not appear on the final report.

I changed the field in the database for the value to appear as text (per suggestion from database people), but that only repeated the information multiple times and the information wouldn't appear.  So went back to original format and trying to figure out in the design phase how to read the dates if crystal sees the dates as "2014-05-" to actually pull the information and change it to "May 2014".   In your experience, where would you insert such a string?  Thanks.

-Maureen

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 13 Nov 2012 at 5:46am
I'm seeing you mention dates in a number of formats.  What, exactly, is the data type of the field that contains the date? Also, please provide sample data fo ALL of the date formats that are shown in the database.
 
Thanks!
 
-Dell
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 13 Nov 2012 at 5:49am
you can evaluate for len, if no date is there,

if len(date)<> 10 then
add the TBD :)
IP IP Logged
tucker2m
Newbie
Newbie


Joined: 04 Aug 2011
Location: United States
Online Status: Offline
Posts: 15
Quote tucker2m Replybullet Posted: 13 Nov 2012 at 8:06am
Where would you put a "len" formula?  I have added the fields directly into a text box and they are in a subreport.  The fields themselves were converted to text using the Format Editor->Date and Time style.  
IP IP Logged
tucker2m
Newbie
Newbie


Joined: 04 Aug 2011
Location: United States
Online Status: Offline
Posts: 15
Quote tucker2m Replybullet Posted: 13 Nov 2012 at 8:22am
Hi there,

the dates are date type tables. In the db itself, they can appear as below:


When adding the field to the report on the db side, I change the table to read as text upon exporting in the CSV files.  So in the CSV file they appear as two different tables with the data appearing as below.

InfVenueEndDate0_key eloans_key InfVenueEndDate InfVenueStartDate
1 1 2013-10- 2013-05-
2 1 2/16/2014 11/17/2013
3 1 6/22/2014 3/15/2014
4 2 2014 2014-01-
5 3 7/13/2014 3/8/2014

So the issue is that in crystal, the data is not pulling for the first because it does not recognize that as a date because in crystal, I have changed the format for the field from a MM/DD/YYYY date/time stamp to appear as "January 01, 2012" text format.  For some reason crystal just suppresses the first incomplete dates so when I run the preview, the field is empty for the corresponding record.  If the date has the correct date format, the full dates appear in the report.  So it is definitely on the crystal side that is is suppressing.

Here is my linking for the fields:


Since I am getting the information from the CSV files, it is definitely something in crystal with how it is reading the data.  Ugh, this is frustrating.


IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 13 Nov 2012 at 8:24am
take the field and add it into a formula, and display the formula not the text field (suppress it)

you can run len against a formula that returns type string


just read what you said about your bad data..


you will have to validate:

if isdate(field) then run logic.

Otherwise you need to be creative, I would import all of if as a string.

Edited by comatt1 - 13 Nov 2012 at 8:26am
IP IP Logged
tucker2m
Newbie
Newbie


Joined: 04 Aug 2011
Location: United States
Online Status: Offline
Posts: 15
Quote tucker2m Replybullet Posted: 13 Nov 2012 at 8:25am
oops, images didn't make it over. 

Start Date End Date
05//2013 10//2013
11/17/2013 02/16/2014
03/15/2014 06/22/2014

IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 13 Nov 2012 at 8:28am
ex. 05//2013

if not(isdate(above value)) then
replace(value, '//', '/TBD/')
IP IP Logged
Page  of 2 Next >>
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.031 seconds.