Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Century part of date is incorrect Post Reply Post New Topic
Author Message
ChzHdGrrl
Newbie
Newbie
Avatar

Joined: 07 Mar 2012
Online Status: Offline
Posts: 10
Quote ChzHdGrrl Replybullet Topic: Century part of date is incorrect
    Posted: 10 Jan 2014 at 5:39am
Hi:
 
I'm working with a system whose backend is written in AcuCobol, which is as alien to me as Urdu. The report is thirteen years old and is really ugly, but I'm trying to solve one of the more pressing and annoying problems with it first.
 
I have a field called Maturity Date. The field has a datatype of "date", and when I browse the data I see a number of dates formatted as MMDDYYYY, all of which appear to be correct. However, several of those dates display in my report with the wrong century (i.e. 19 as opposed to 20).
 
For example, when I browse the data for this field I see a number of dates 12/31/2049, but in the report those same dates display as 12/31/1949.
 
I have tried converting the field to a DATETIME and then done a DATEADD to the year, but THEN I get 4/10/1950 (which means it's adding to the days, not years). As an experiment I tried adding 100 to both the days and months, and neither yields the correct century.
 
I'm out of ideas. Anyone?
 
Thanks,
Chzhdgrrl
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 10 Jan 2014 at 6:39am
I think that converting to a string and building it up to look like you need (example):
totext({datefield},"MM/DD/YYYY")    (I may not have the formatting right, might be something like "mm/dd/yyyy")

I hope this helps.
IP IP Logged
ChzHdGrrl
Newbie
Newbie
Avatar

Joined: 07 Mar 2012
Online Status: Offline
Posts: 10
Quote ChzHdGrrl Replybullet Posted: 10 Jan 2014 at 6:50am
I tried converting to a string and ended up with dates that look like this:
 
05/DD/YYYY
10/DD/YYYY
04/DD/YYYY
 
WTH?
IP IP Logged
ChzHdGrrl
Newbie
Newbie
Avatar

Joined: 07 Mar 2012
Online Status: Offline
Posts: 10
Quote ChzHdGrrl Replybullet Posted: 10 Jan 2014 at 7:02am
I was mistaken in my original post....the source data is also wrong. The dates as displayed in the user interface are correct, but when I browse the data in its native field (not the field resulting from the conversion), it's wrong.
 
Any suggestions?
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 10 Jan 2014 at 7:37am
If the source data is incorrect, then it would require some 'smart' programming to figure out how to correct the dates.  Which probably should be done on the database side.  

As far as the totext function.   I did not look up to see the correct formats for the dates, I relied on my memory which is rather faulty.
IP IP Logged
ChzHdGrrl
Newbie
Newbie
Avatar

Joined: 07 Mar 2012
Online Status: Offline
Posts: 10
Quote ChzHdGrrl Replybullet Posted: 10 Jan 2014 at 7:40am
Sadly, this is an OTS product and I don't speak AcuCobol, so any database side work will come with a pricetag. :(
 
Thanks anywho.
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 10 Jan 2014 at 10:29am
if there are not a lot of wrong dates you could just do an
if statement.
this might be a bad solution if the future dates might be also incorrect.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Jan 2014 at 11:28am
just a suggestion but it might be storing the date as an integer of total number of days (or minutes or something) from a starting date (maybe datetime?).
if that is the case you can use the original data that is really an integer in a dateadd to whatever the startingdate is to get to the correct date in crystal.
If you can find a data field, see the raw field data in its native program and then see the same field as it is dispalyed as in the GUI that shows it correctly you might be able to determine it.
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.016 seconds.