View Full Version : Displaying Dates
grapnell 04-10-2008, 05:38 AM I am trying to create a report in Crystal Reports XI using DacEasy v 14. The problem I am having is that dates are stored in the following format in the database:
YYYYMMDD
for example 20080113 for 2008, Jan 13. How can I get it to convert that date and display a human readable date such as 01/13/2008? Thanks for any input.
Jeff
boblarson 04-10-2008, 05:43 AM Look into using the CDate and Left/Mid/Right functions -
Air code (meaning not tested):
CDate(Mid(5,DateFieldName,2) & "/" & Right(DateFieldName,2) & "/" & Left(DateFieldName,4))
grapnell 04-10-2008, 06:00 AM I actually tried that, but the problem is that the Date stored in the database is in of type number, and cdate expects type string. Is there a way that I can first convert it to a string?
Thanks again,
Jeff
boblarson 04-10-2008, 06:03 AM I actually tried that, but the problem is that the Date stored in the database is in of type number, and cdate expects type string. Is there a way that I can first convert it to a string?
Thanks again,
Jeff
CDate SHOULD'NT expect a string. CDate is SUPPOSED to convert ANY other datatype to a date. But, if you have to use CStr to encapsulate the whole thing and then use CDate around that.
grapnell 04-10-2008, 06:58 AM Thanks for all the help, I got it to work finally. It wasn't the CDate function that wanted strings, but the left,right and mid functions that wanted strings. so I encapsulated the number in CSTR before I encapsulated it in left/right/mid and it worked. Thanks again.
Jeff
Brianwarnock 04-10-2008, 08:08 AM Bob
I've noticed that posters tend to prefer CDate to Dateserial, why is that.?
Dateserial gives a date in the default format of the system without any problems as far as I can see.
Dateserial(left(datefield, 4),mid(datefield,5,2),right(datefield,2)) seems very straight forward, is there a possible problem I don't know of.
Thanks
Brian
boblarson 04-10-2008, 08:22 AM Bob
I've noticed that posters tend to prefer CDate to Dateserial, why is that.?
Dateserial gives a date in the default format of the system without any problems as far as I can see.
Dateserial(left(datefield, 4),mid(datefield,5,2),right(datefield,2)) seems very straight forward, is there a possible problem I don't know of.
Thanks
Brian
Could be that it is just hasn't gotten its due. I don't know if it is available within Crystal Reports, but it would be a good one to use. I'm not used to using it and a lot of times I forget about it. So that is a likely reason.
Brianwarnock 04-10-2008, 08:32 AM OOps never noticed that it was Crystal Reports, I have no experience there.
Thanks for the response, I guess we all use what we are used to.
Brian
|
|