Link to home
Start Free TrialLog in
Avatar of tam97
tam97

asked on

DB Grid Question - Urgent !

Could someone please advise on how I can get the DB Grid component in Delphi 3 to display a date field as a four digit year.

I have found a couple of components e.g. Edit and DBEdit which takes the date in as a four digit year and the Paradox tables accept the year in four digits, but when it comes to displaying the date,niether the DB Grid/DB Edit or DB Lable in Delphi 3 displays the year 2000 as that, they display it as 00.

Can someone help or even suggest a site where I can locate a component to do the job.

Thanks in advance

Avatar of gaona
gaona

Dear Advance,  
 
If that you want it is an entrance and an exit in a DBGrid or DBEdit in the format '' dd/mm/yyy '', make the following:  
In the property Display format of the wanted field he types the string: [''dd/mm/yyyy '']  
observe that as this property he/she has a string as property, don't type quotation marks and yes two comas.  
In the property EditMask, type the string [!99/99/0000;1;_] without quotation marks or comas.  
I tested this solution and she worked.  
 
Hugs, Gaona.  
 
Obs.: Excuse me if my English is not good.
Dear Advance,  
 
If that you want it is an entrance and an exit in a DBGrid or DBEdit in the format 'dd/mm/yyyy', make the following:  
In the property Display format of the wanted field he types the string: [''dd/mm/yyyy'']  
observe that as this property he/she has a string as property, don't type quotation marks and yes two comas.  
In the property EditMask, type the string [!99/99/0000;1;_] without quotation marks or comas.  
I tested this solution and she worked.  
 
Hugs, Gaona.  
 
Obs.: Excuse me if my English is not good.
Avatar of tam97

ASKER

Thanks for speedy reply, I'll try your suggestion and get back to you.

Regards John
Avatar of tam97

ASKER

Gaona

I think I clicked the wrong option as it has came up as a rejected answer which it is not, sorry !

I'll get back to you

Regards John
Uses BDE;
Procedure fDbiSetDateFormat;
var
  fDate : FMTDate;
begin
  fDate.szDateSeparator := '/';          { Specifies date separator character }
  fDate.iDateMode := 0;                 { Date format. 0 = MDY, 1 = DMY, 2 = YMD. }
  fDate.bFourDigitYear := TRUE;         { If TRUE, write year as four digits. }
  fDate.bYearBiased := FALSE;            { On input add 1900 to year if TRUE. }
  fDate.bMonthLeadingZero := FALSE;      { Month displayed with a leading zero if TRUE. }

  fDate.bDayLeadingZero := FALSE;        { Day displayed with leading zero if TRUE. }

  Check(DbiSetDateFormat(fDate));
end;

Looks like THE thing? Well, I'm not sure. I think it has a different purpose:

Usage

The date format is used by QBE (Query By Example language) for input and wildcard character matching. It is also used by batch operations (such as DbiDoRestructure and DbiBatchMove) to handle data type coercion between character and date types.

(BDE API help on value DbiSetDateFormat}

I also found another very stupid line in the help:
"Paradox date fields can contain any valid date from January 1, 9999 BC to December 31, 9999 AD. To change the default display of a date field, use Paradox."

Well, it seems like you have to install Paradox - Borland moves to MS policy? ("You can't shoot your foot using Access. To shoot your right foot install FoxPro. To shoot your left foot install Informix...")

I also searched for Grid components in Delphi pages, but didn't find any. In case you don't know:
http://www.delphipages.com/
http://bes.trendline.co.il/torry/
http://sunsite.icm.edu.pl/delphi/
Avatar of tam97

ASKER

Hi Matvey

Thanks for your detailed reply, I'm quite new to Delphi so excuse the following (possibly stupid)comment to your reply.

I'm not sure how the procedure you quoted should be implemented, or where in the program, could you assist ?.

Good point made about (Borland/MS) !, I did set the date field in Paradox with a four figure mask which it accepted OK, the Paradox field will accept 2000 but the bloody DB Grid only displays 00.

Like yourself I've tried the sites you gave to no avail.

Thanks again for your time, I'll set about trying your procedure.

Regards John
Just add the BDE unit on the top of yours and copy this procedure. You can call it after you open your table (eg initialize the BDE). My point was that I'm not sure it's working - I posted it's description which says that DbiSetDateFormat is meant for BatchMoves or something. Too bad :(
Tell me if it produces a result at all. You can also do another thing of the same king: goto BDE administrator-configuration tab-system-formats-DATE. Here you can set the formatting of date, but it seems to have no effect. Can anybody else exaplin it maybe?
ASKER CERTIFIED SOLUTION
Avatar of gaona
gaona

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dear Tam97
Have you tried setting WINdows97/Start/Settings/regional seettings/Date and choose the format(4 figure date format) that you desire.This is what I have been doing and is working fine
Avatar of tam97

ASKER

Hi Venks

Have tried your suggestion, Works perfectly first time,
thank you very much indeed.

I have to award the points to you as you supplied the precise answer, but I would like to thank the other experts who gave their time trying to help.

Many thanks again

Regards John
As per tam97 reply she seems to have accepted my reply and i am really glad i could be of some use.Incidentally this was my first answer and feel honoured that my first attempt has been successful
How is it that tam97 has accepted  my answer and some one else(gaona) gets the point.May be some one will clarify this
Avatar of tam97

ASKER

Venks

Your reply was spot on and you deserved the points, now that you have pointed out that the points have gone to another expert I can only assume that when I accepted your answer the system must have been sitting or ralating to an original part of the history.

I'm sorry this happened and it's most certainly been my fault, could you contact the administrator and have the points awarded to yourself, if for no other reason that a matter of principal, I'll see what I can do my end.

I hope that this does not put you off answering peoples questions as you have assisted many with the same problem.

Rgds John
I have poted a question to the customer service forum to put the matters right
Thanks for the reply anyway
tam97,
tam97
There are two ways to post at a question - comments or an answer.  When you grade a question always make sure that the expert you want to receive the points for the question has the proposed answer.  

If the expert you want to receive the points does not have the proposed answer you can reject the current proposed answer by choosing the option below the question "Reopen question to other experts".  Add a comment requesting that the expert you want to award points to post an answer.

OPTION AT QUESTION WITH ANSWER:
1. Grade linda's answer:
   A: Excellent! B: Good! C: Average.
   D: Acceptable. E: Reopen question to other experts.

venks,
Thanks for your answer on this question.  Look in the new questions for one to award you points for your answer.

Linda Gardner
Customer Service @ Experts Exchange
Avatar of tam97

ASKER

Hi Linda

Thanks for the advice will carry out your instructions from now on.

Rgds John
Dear Linda
I am very happy that the matter has been set right and that too promptly.This is what makes the expert exchange a great place.
Venks