?
Solved

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

Posted on 2000-03-09
5
Medium Priority
?
226 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 200 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

719 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