[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

FormatDateTime with NULL Date Fields

Posted on 2004-04-10
5
Medium Priority
?
531 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 90 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

Industry Leaders: 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

656 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