Solved

How can I get the year as a four-digit number in QuickRep?

Posted on 2000-03-09
5
220 Views
Last Modified: 2010-04-04
I am using D3 and QR2.0K for D3. In my delphi project, I linked the report to TQuery component, I used the TQRExpr component to display/print the year, the TQRExpr component Expression property is [RepDate].

The TQRExpr component just can show the year as a two-digit number. How can I get the year as a four-digit number?


I have another question, please look at http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=10302123

Regards, supwang
0
Comment
Question by:SupWang
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:simonet
ID: 2603446
The trick is to, right before issueing the QuickRep.Preview method, set the ShortDateFormat global variable to something like

ShortDateFormat := 'dd/MM/yyyy';

Then after the report is through, change ShortDateFormat back to its original state (which you save on another string variable).

The reason this trick works is because the TQRExpr component uses Delphi's built-in date and string handling routines, which, in turn, rely on the ShortDateFormat variables, which you can change at will, without messing up with the computer's system-wide config.

Yours,

Alex
0
 
LVL 15

Accepted Solution

by:
simonet earned 50 total points
ID: 2603463
Another option is to change the value that the TQRExpr prints right before it gets printed:

procedure TForm1.QRExpr1Print(sender: TObject; var Value: String);
begin
   Value := FormatDateTime('mm/dd/yyyy', StrToDate(Value));
end;

The above will read the Value variable, change it to Date and then Change it back to a String, however using 4 digits for the year.

Although this works, the first method I outlined is a cleaner way to have it working.

You can always, of course, go to the  Control Panel and change the short date format to a 4-digit year format.

Yours,

Alex

0
 
LVL 2

Author Comment

by:SupWang
ID: 2603631
Hi Alex,
Thanks.
I like the first way. I also know the second, but I don't want to use it.
I can't find the help of "ShortDateFormat" in D3, But find it in D4. :-)
How do you handle the display format of the year? I want to set all the date to yyyy-m-d in
the program start-up, How do you think about it?

and Please look at my new question:
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=10308596

Regards, supwang
0
 
LVL 15

Expert Comment

by:simonet
ID: 2604297
I usually change ShortDateFormat in the project source (the .DPR file), so it's consistent along the whole program.

I warn you not to change the date format to unusual formats, because that may confuse your users (they may not be used to the format you're suggesting), but that's entirely up to you.

Alex
0
 
LVL 2

Author Comment

by:SupWang
ID: 2604376
Alex, Have you see my another question? need your help.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now