Questions tagged [tdatetime]
48 questions
31
votes
11 answers
Declare a TDateTime as a Const in Delphi
As far as I know there is no way to do this, but I am going to ask just in case someone else knows how to do this. How can I declare a date as a const in Delphi?
The only solution I have found is to use the numeric equivalent, which is kind of a…

Jim McKeeth
- 38,225
- 23
- 120
- 194
19
votes
2 answers
How can I distinguish TDateTime properties from Double properties with RTTI?
Using the RTTI system in Delphi 2010, is there any way to find out if a property is a TDateTime? It's currently treating it as a double whenever I call back asVariant and also if I check the property type. Is this due to the fact it can only see the…

Barry
- 1,084
- 1
- 8
- 22
17
votes
2 answers
Conversion with StrToDateTime and TFormatSettings does not work
This code should work in Delphi XE2, but it gives "not a valid date and time" error in StrtoDateTime conversion:
procedure TForm2.Button1Click(Sender: TObject);
var
s: string;
d: TDateTime;
FmtStngs: TFormatSettings;
begin
…

Moore
- 221
- 1
- 4
- 12
6
votes
2 answers
What is the best way of detecting that a Delphi TWebBrowser web page has changed since I last displayed it?
I want to display a 'news' page in a form using Deplhi TWebBrowser. The news page is a simple HTML page which we upload to our website from time to time and may be output from various tools. The display is fine but I'd like to know in my app whether…

Brian Frost
- 13,334
- 11
- 80
- 154
6
votes
3 answers
Convert UTC string to TDatetime in Delphi
var
tm : string;
dt : tdatetime;
tm := '2009-08-21T09:11:21Z';
dt := ?
I know I can parse it manually but I wonder if there is any built-in function or Win32 API function to do this ?

Irwan
- 783
- 1
- 13
- 28
5
votes
2 answers
How does Delphi calculate TDateTime as a Float value?
I am new in Delphi programming.
While going through the Data Types in Delphi I found TDateTime.
While using it in my test application I come to know that the TDateTime Object provide me a Float\Double value.
I am little curious about TDateTime How…

A B
- 1,461
- 2
- 19
- 54
5
votes
3 answers
How know type variable is TDateTime, TDate and TTime in Delphi
I need know type variable TDateTime, TDate and TTime.
Anyone have any idea how to do this?
I used the code below, the result is "Is NOT TDateTime", "Is NOT TDate", "Is NOT Ttime"
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
…

Johni Douglas Marangon
- 517
- 5
- 15
4
votes
3 answers
Subtract two TDATETIME variables in Delphi and return the result in minutes
I have two TDateTime variables, like this:
s := StrToDateTime('03/03/2017 10:10:12');
e := StrToDateTime('04/04/2017 10:10:12');
I need to find out the difference between them, in hh:mm:ss format.
The ...Between() functions are not helping me here.

Tina Soltanian
- 81
- 1
- 2
- 8
4
votes
1 answer
Delphi tdatetime to Java Date/Calender
I have a question for you Delphi-cracks out there.
My Java application is communcating with a Delphi Application.
The Delphi Application shows some date values within its UI which should be transfered into the Java application via file.
But instead…

dreamwalker7
- 89
- 5
4
votes
1 answer
How do I check if a Variant is a TDateTime?
I have an object, that has one value, but that value can either be an integer, string, boolean or TDateTime. So, it is a Variant.
I use VarType() to check its type, but since VarType() has no 'varDate' or 'varDateTime', I am using 'varDouble',…

Svip
- 2,958
- 3
- 22
- 33
3
votes
0 answers
Delphi does not infer TDateTime for local variables
I have a routine that fetches a TDateTime from a database. I fetch it like this in another routine:
var lCrmStartDate := self.GetCrmStartDate;
This results in lCrmStartDate being inferred as Extended, giving me all sorts of trouble.
I now fetch the…

Paul Sinnema
- 2,534
- 2
- 20
- 33
3
votes
1 answer
Convert a TValue into TDateTime
How can I convert a TValue in TDateTime?
I see there are methods like AsInteger, AsDouble, etc. but nothing for TDateTime.
var
c : TRttiContext;
t : TRttiType;
f : TRttiField;
fieldValue : TValue;
fieldDateValue : TDateTime;
begin
c :=…

Alberto
- 2,881
- 7
- 35
- 66
3
votes
1 answer
Why do TDateTime calculations involve variants?
Simple sample code below, with the generated assembler. I'm surprised that the generated code involves variants. The Delphi equivalent certainly doesn't.
TDateTime t1;
TDateTime t2;
...
int x = 2 * (t2 - t1);
Generated code.
Unit23.cpp.18: int x…

Roddy
- 66,617
- 42
- 165
- 277
3
votes
2 answers
Specific validation of dates using TryStrToDate
I'm trying to validate dates entered by the user using TryStrToDate to ensure that they can be properly displayed on the screen of the application I'm working on, but don't know exactly how it all works. I want to be able to return False when a…

Alex Gorski
- 41
- 1
- 5
2
votes
1 answer
Delphi TDateTime variable will not initialize in Delphi 2010
I have created a simple form in Delphi 2010 with a single button in the code for the button I put:
procedure TForm1.Button1Click(Sender: TObject);
var
myDateTime:TDateTime;
begin
myDateTime:=now; // shows as 12/30/99 in debugger
end;
When…

Bill Seven
- 768
- 9
- 27