Solved

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

Posted on 2000-03-09
5
221 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
System restore point 4 91
How to use Hibernate  and delphi ? Does anyone know any tutorial? 2 144
Mydac connection data base issue 3 135
Path  to current project in Delphi. 2 71
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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

932 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

19 Experts available now in Live!

Get 1:1 Help Now