kretzschmar
asked on
qow 18: how to force a four digit year display for a db-date-value
hi experts,
i am restarting qow = question of the week :-)
(since it is possible now to post 25 pt. questions)
each week i will introduce a new simple? question.
now qow 18
sorry, top 15 experts, you are not allowed to solve this
q, only other can solve this question :-(
well the question is:
how to force a four digit year display
in data-aware controls
for a db-date-value?
(i've two simplew solutions in mind and some other)
each different solution may get 25 pts
let see
meikl ;-)
i am restarting qow = question of the week :-)
(since it is possible now to post 25 pt. questions)
each week i will introduce a new simple? question.
now qow 18
sorry, top 15 experts, you are not allowed to solve this
q, only other can solve this question :-(
well the question is:
how to force a four digit year display
in data-aware controls
for a db-date-value?
(i've two simplew solutions in mind and some other)
each different solution may get 25 pts
let see
meikl ;-)
Double click in the Ttable or Tquery.
Right button of the mouse over the fields Editor.
Add Fields.
Write in the DisplayFormat something like this:
dd/mm/yyyy.
And all the Data aware Controls depending from this Table or Query will show the Date field as 30/12/2002...
Best Regards.
Marcos.
Right button of the mouse over the fields Editor.
Add Fields.
Write in the DisplayFormat something like this:
dd/mm/yyyy.
And all the Data aware Controls depending from this Table or Query will show the Date field as 30/12/2002...
Best Regards.
Marcos.
go to Start->Control Panel-> Regional Settings u configure your date here to 4 digits.
i work with TEdits
Edit1.Text:=Formatdatetime ('dd/mm/yy yy',now) or
Edit1.Text:=Formatdatetime ('dd/mm/yy yy',table1 .fieldbyna me('mydate ').asdatet ime);
Accept the answer if help you thanks
i work with TEdits
Edit1.Text:=Formatdatetime
Edit1.Text:=Formatdatetime
Accept the answer if help you thanks
ASKER
hi jamiguel,
there is no need to answer the question,
since each solution gets points.
and its just not polite to answer a question,
when others already has given a solution
in previous comments
for the future, please,
do rather comment than answer a question
i reject your answer,
to keep this q open for other solutions
i count for you 1 solution
>go to Start->Control Panel-> Regional Settings u
>configure your date here to 4 digits.
for this
>Edit1.Text:=Formatdatetim e('dd/mm/y yyy',now) or
>Edit1.Text:=Formatdatetim e('dd/mm/y yyy',table 1.fieldbyn ame('mydat e').asdate time);
as i talked about dbaware-controls, i will count this,
if you can also provide the other direction
?table1.fieldbyname('mydat e').asdate time := ...
if you can provide this, then it counts as your second solution, and you will get 50 pts
drdelphi, marcoszorrilla are counting both
waiting for other solutions
i have already two other solutions in mind,
additional to the given solutions here.
meikl ;-)
there is no need to answer the question,
since each solution gets points.
and its just not polite to answer a question,
when others already has given a solution
in previous comments
for the future, please,
do rather comment than answer a question
i reject your answer,
to keep this q open for other solutions
i count for you 1 solution
>go to Start->Control Panel-> Regional Settings u
>configure your date here to 4 digits.
for this
>Edit1.Text:=Formatdatetim
>Edit1.Text:=Formatdatetim
as i talked about dbaware-controls, i will count this,
if you can also provide the other direction
?table1.fieldbyname('mydat
if you can provide this, then it counts as your second solution, and you will get 50 pts
drdelphi, marcoszorrilla are counting both
waiting for other solutions
i have already two other solutions in mind,
additional to the given solutions here.
meikl ;-)
ASKER
hi jamiguel,
there is no need to answer the question,
since each solution gets points.
and its just not polite to answer a question,
when others already has given a solution
in previous comments
for the future, please,
do rather comment than answer a question
i reject your answer,
to keep this q open for other solutions
i count for you 1 solution
>go to Start->Control Panel-> Regional Settings u
>configure your date here to 4 digits.
for this
>Edit1.Text:=Formatdatetim e('dd/mm/y yyy',now) or
>Edit1.Text:=Formatdatetim e('dd/mm/y yyy',table 1.fieldbyn ame('mydat e').asdate time);
as i talked about dbaware-controls, i will count this,
if you can also provide the other direction
?table1.fieldbyname('mydat e').asdate time := ...
if you can provide this, then it counts as your second solution, and you will get 50 pts
drdelphi, marcoszorrilla are counting both
waiting for other solutions
i have already two other solutions in mind,
additional to the given solutions here.
meikl ;-)
there is no need to answer the question,
since each solution gets points.
and its just not polite to answer a question,
when others already has given a solution
in previous comments
for the future, please,
do rather comment than answer a question
i reject your answer,
to keep this q open for other solutions
i count for you 1 solution
>go to Start->Control Panel-> Regional Settings u
>configure your date here to 4 digits.
for this
>Edit1.Text:=Formatdatetim
>Edit1.Text:=Formatdatetim
as i talked about dbaware-controls, i will count this,
if you can also provide the other direction
?table1.fieldbyname('mydat
if you can provide this, then it counts as your second solution, and you will get 50 pts
drdelphi, marcoszorrilla are counting both
waiting for other solutions
i have already two other solutions in mind,
additional to the given solutions here.
meikl ;-)
ASKER
hi jamiguel,
there is no need to answer the question,
since each solution gets points.
and its just not polite to answer a question,
when others already has given a solution
in previous comments
for the future, please,
do rather comment than answer a question
i reject your answer,
to keep this q open for other solutions
i count for you 1 solution
>go to Start->Control Panel-> Regional Settings u
>configure your date here to 4 digits.
for this
>Edit1.Text:=Formatdatetim e('dd/mm/y yyy',now) or
>Edit1.Text:=Formatdatetim e('dd/mm/y yyy',table 1.fieldbyn ame('mydat e').asdate time);
as i talked about dbaware-controls, i will count this,
if you can also provide the other direction
?table1.fieldbyname('mydat e').asdate time := ...
if you can provide this, then it counts as your second solution, and you will get 50 pts
drdelphi, marcoszorrilla are counting both
waiting for other solutions
i have already two other solutions in mind,
additional to the given solutions here.
meikl ;-)
there is no need to answer the question,
since each solution gets points.
and its just not polite to answer a question,
when others already has given a solution
in previous comments
for the future, please,
do rather comment than answer a question
i reject your answer,
to keep this q open for other solutions
i count for you 1 solution
>go to Start->Control Panel-> Regional Settings u
>configure your date here to 4 digits.
for this
>Edit1.Text:=Formatdatetim
>Edit1.Text:=Formatdatetim
as i talked about dbaware-controls, i will count this,
if you can also provide the other direction
?table1.fieldbyname('mydat
if you can provide this, then it counts as your second solution, and you will get 50 pts
drdelphi, marcoszorrilla are counting both
waiting for other solutions
i have already two other solutions in mind,
additional to the given solutions here.
meikl ;-)
ASKER
:-( can't reject the answer, ex-ex seems to be a bit buggy
ASKER
hu, rejected,, sorry for the thretimes-post ;-)
waiting for other solutions
i have already two other solutions in mind,
additional to the given solutions here.
meikl ;-)
waiting for other solutions
i have already two other solutions in mind,
additional to the given solutions here.
meikl ;-)
I always save dates as string fields in my databases. Listening...
ASKER
i have already two other solutions in mind,
additional to the given solutions here.
no one else?
geo, just listening?
its really not a hard question
closing thread on friday
meikl ;-)
additional to the given solutions here.
no one else?
geo, just listening?
its really not a hard question
closing thread on friday
meikl ;-)
Here's yet another:
procedure TForm1.MakeDateText(Sender : TField; var Text: String;DisplayText:Boolean );
begin
if (Sender.DataType=ftDateTim e) then Text:=FormatDateTime('YYYY DD,MM',StrToDateTime(Sende r.AsString ));
Displaytext:=True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DbEdit1.Field.OnGetText:=M akeDateTex t;
end;
procedure TForm1.MakeDateText(Sender
begin
if (Sender.DataType=ftDateTim
Displaytext:=True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DbEdit1.Field.OnGetText:=M
end;
ASKER
well, drdelphi,
this was one of the two i had in mind,
but also here is the other direction needed
(because usual dataaware-controls are also for editing)
just provide a onSetText-method to transform back,
and you get additional 25 pts
one solution already left
meikl ;-)
this was one of the two i had in mind,
but also here is the other direction needed
(because usual dataaware-controls are also for editing)
just provide a onSetText-method to transform back,
and you get additional 25 pts
one solution already left
meikl ;-)
You're making me work here!<g>
procedure TForm1.MakeDateText(Sender : TField; var Text: String;DisplayText:Boolean );
begin
if (Sender.DataType=ftDateTim e) then Text:=FormatDateTime('YYYY MMM DD',StrToDateTime(Sender.A sString));
Displaytext:=True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DbEdit1.Field.OnGetText:=M akeDateTex t;
DbEdit1.Field.OnSetText:=M akeTextDat e;
end;
procedure TForm1.MakeTextDate(Sender : TField; const Text: String);
begin
Sender.AsDateTime:=StrToDa teTime(for matDatetim e('mm/dd/y yyy',StrTo DateTime(t ext)));
end;
procedure TForm1.MakeDateText(Sender
begin
if (Sender.DataType=ftDateTim
Displaytext:=True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DbEdit1.Field.OnGetText:=M
DbEdit1.Field.OnSetText:=M
end;
procedure TForm1.MakeTextDate(Sender
begin
Sender.AsDateTime:=StrToDa
end;
I'm sure this works with dataaware components, though not tested.
In the Create in the application:
shortdateformat:='dd/mm/yy yy';
John.
In the Create in the application:
shortdateformat:='dd/mm/yy
John.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yep johnch,
this was my last solution, i had in mind,
its the simplest, does affect all date-displays,
except the tdatetimepicker display,
and this only for the current app instance
(os is not affected)
drdelphi,
i'm just impressed, how much you work,
for 25 pts. :-))
well, someone with a courious solution?
closing thread tomorrow,
each solution gets 25 pts (A Graded)
jamiguel,
the other direction of your second part solution
is still missing. post it here until tomorrow and you get
25 pts for this solution also.
meikl ;-)
this was my last solution, i had in mind,
its the simplest, does affect all date-displays,
except the tdatetimepicker display,
and this only for the current app instance
(os is not affected)
drdelphi,
i'm just impressed, how much you work,
for 25 pts. :-))
well, someone with a courious solution?
closing thread tomorrow,
each solution gets 25 pts (A Graded)
jamiguel,
the other direction of your second part solution
is still missing. post it here until tomorrow and you get
25 pts for this solution also.
meikl ;-)
ASKER
i grade this q,
because its the simplest clean solution
the others
DrDelphi 50 pts.
marcoszorrilla 25 pts.
jamiguel 25 pts.
may watch out for their points
thanks for participating on this quest
meikl ;-)
because its the simplest clean solution
the others
DrDelphi 50 pts.
marcoszorrilla 25 pts.
jamiguel 25 pts.
may watch out for their points
thanks for participating on this quest
meikl ;-)
ok
in the component ttable or tquery i can make double click and add all fields(press mouse right click and see a popupmenu same: add fields,delete fields ...), chose the fields that we want see in the dbgrid and press button ok, i choose the field (of type datetime) and then press F11 in proeprty Dismplayformat of the field i can type: dd/mm/yyyy
other
query1.Fields[0].DisplayFo rmat:='dd/ mm/yyyy';
thanks
:)
in the component ttable or tquery i can make double click and add all fields(press mouse right click and see a popupmenu same: add fields,delete fields ...), chose the fields that we want see in the dbgrid and press button ok, i choose the field (of type datetime) and then press F11 in proeprty Dismplayformat of the field i can type: dd/mm/yyyy
other
query1.Fields[0].DisplayFo
thanks
:)
ASKER
already commented by drdelphi, jamiguel
jamiguel, get your points at
https://www.experts-exchange.com/questions/20318114/for-jamiguel-qow-18-for-digit-date-display-on-data-aware-controls.html
marcoszorrilla, get your points at
https://www.experts-exchange.com/questions/20318113/for-marcoszorrilla-qow-18-for-digit-date-display-on-data-aware-controls.html
meikl ;-)
jamiguel, get your points at
https://www.experts-exchange.com/questions/20318114/for-jamiguel-qow-18-for-digit-date-display-on-data-aware-controls.html
marcoszorrilla, get your points at
https://www.experts-exchange.com/questions/20318113/for-marcoszorrilla-qow-18-for-digit-date-display-on-data-aware-controls.html
meikl ;-)
Typecast the field as TDateTimeField:
TDateTimeField(query1.Fiel