Solved

FormatDateTime with NULL Date Fields

Posted on 2004-04-10
5
512 Views
Last Modified: 2010-04-05
Hi all,
  When using FormatDateTime routine with a NULL Date fields, this function return 30/12/1899.
  So, How to avoid this undesirable value.

Thanks,
Khalid.
0
Comment
Question by:Qosai_DBA
[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 27

Accepted Solution

by:
kretzschmar earned 30 total points
ID: 10795976
if dataset.fieldbyname('DateFieldName').isNull then
  result := ''
else
  result := formatDateTime(...);

meikl ;-)
0
 
LVL 1

Author Comment

by:Qosai_DBA
ID: 10796505
Hi kretzschmar,
  Your example is correct when use FormatDateTime with Database Fields, but what can I do when using variables of TDateTime as a datatype with no value?

Thanks,
khalid.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10796518
if datevalue = 0 then
  result := ''
else
  result := formatDateTime(...);

meikl ;-)
0
 
LVL 1

Author Comment

by:Qosai_DBA
ID: 10800020
Hi again,
I'm sorry kretzschmar, maybe I'm facing some problem.
this's my code

procedure TForm1.Button1Click(Sender: TObject);
var v_Date: TDatetime;
begin
  if(v_Date = 0)then
    Form1.Label1.Caption:= ''  // Return 30/12/1899
  else
    Form1.Label1.Caption:= FormatDateTime('dd/mm/yyyy', v_Date);
end;

Thanks,
Khalid.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10800126
well khalid,

which value should v_date have?
(currently it may random, because of a local uninitilaized var)

meikl ;-)
0

Featured Post

Technology Partners: 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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

726 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