Displaying Dates

grapnell

New member
Local time
Yesterday, 23:21
Joined
Apr 10, 2008
Messages
3
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
 
Look into using the CDate and Left/Mid/Right functions -

Air code (meaning not tested):
Code:
CDate(Mid(5,DateFieldName,2) & "/" & Right(DateFieldName,2) & "/" & Left(DateFieldName,4))
 
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
 
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.
 
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
 
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
 
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.
 
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
 

Users who are viewing this thread

Back
Top Bottom