Solved

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

Posted on 2000-03-09
5
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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