Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting the Date in Crystal 1

Status
Not open for further replies.

Chris36695

IS-IT--Management
Feb 24, 2004
4
US
I'm a new Crystal Report user (I have training scheduled for the end of next month, but I need some help now).
My database shows dates like this: 01/01/2004, but Crystal converts that date to look like this: 2004-01-01 00:00:00. How can I format the date in Crystal to look like 01/01/2004?
 
Right Click the field.
Choose format field from the pop up menu.
Click the Date/Time tab.
Highlight "03/01/1999" from the style list.
Click OK.

You can also force the formatting of the date inside of a formula like this:

ToText({table.date},"MM/dd/yyyy");

~Brian
 
The Date/Time tab does not show up of the Format Editor when I right click the field. I get the Paragraph Formatting tab instead.
 
What is the field type? The options you are getting are normally available for Text objects. Have you tried creating a formula as suggested in Brian's post?

Kchaudhry
 
Yes, I tried ToText({query.DUE_DATE},"MM/dd/yyyy");
I get a message saying "Too many aurguments given to this function".
 
Ok, then you will need to price it together.

You can either convert it to a Date,
Code:
stringVar array strDate := Split(Split({table.date}," ")[1],"-");

CDate(Val(strDate[1]),Val(strDate[2]),Val(strDate[3]));
and then format it once it is on the report.

OR

Just create the format you want in the formula:
Code:
stringVar array strDate := Split(Split("2004-01-01 00:00:00"," ")[1],"-");

strDate[2] + "/" + strDate[3] + "/" + strDate[1];

~Brian
 
Rather than just supplying a formula, I'll try to empower you to resolve this type of issue going forward.

You paragraph :"My database shows dates like this: 01/01/2004, but Crystal converts that date to look like this: 2004-01-01 00:00:00. How can I format the date in Crystal to look like 01/01/2004?" is suspect on several levels.

Your database probably does not show dates as 01/01/2004, and Crystal isn't converting the date.

The problem with many people responding here is that they don't bother to learn about the technical details, and users often time have no idea what they are.

When posting, supply some essential information, such as:

Crystal version
Database used
Example data (right click a field and select browse data to learn it's data type and some of the data in the table)
Expected output

You handled the last 2 in part, but omitted the basics. Kchaudry rightfully requested that you explain the data type, which you decided was meaningless.

If this is a datetime field in a SQL Server database (my guess), there isn't a type date, so a time is always stored with it. However later you state that you can't use a totext() against the field, so how could Crystal be converting it to a datetime as in your first post if totext doesn't work?

If you can't format it as a date, it isn't a date, so learn what it really is (a tsring formatted as a date shouldn't be described as a date, it should be desribed as a string formatted as a date)...

Your post contradicts itself, and this is such a basic request that both the experts and the poster are to blame for not stopping, thinking and discovering what's really going on.

For the experts: the users are always completely insane and are incapable of using text to describe their problem.

For the users: the experts are so dumb that if you don't completely spell it out for them, they'll spew random thoughts all day long like 2 year olds (as evidenced with my post...).

-k
 
My problem was not knowing the technical terminology to properly ask the question. I'm a data analyst, not a IT person. Large Corporations, like I work for, continue to reduce their IT work force and place some of their former job responsibilities on other employees such as myself.
I always appreciate any help or tips people can give me and I'm certainly not scared to ask someone for help when I run in to a problem that I can't resolve.
Synapsevampire, reading your response, you came across to me as being very arrogant. Just don't make the mistake of confusing education with intelligence.

Bdreed & kchaudhry, thanks for taking the time to try and help. This was the first report that I've ever built in Crystal and trying your tips did help me learn a few things. I've copied these tips, along with several others that you both have given to other people, in to a file just in case another issue arises.
My problem was solved by this formula: CDATE({Query.DUE_DATE}[6 to 7] + "/" + {Query.DUE_DATE}[9 to 10] + "/" + {Query.DUE_DATE}[1 to 4]). It may not be the best way of doing it, but it worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top