hidrau
asked on
datetime to integer
Hello guys,
I have a date and time variable and I would like to transform it in an integer value so that I can use
the value to compares,
Example:
10/08/2007 10:45
10/08/2007 10:47
10/08/2007 10:58
10/08/2007 10:15
I have a date and time variable and I would like to transform it in an integer value so that I can use
the value to compares,
Example:
10/08/2007 10:45
10/08/2007 10:47
10/08/2007 10:58
10/08/2007 10:15
you can adress a tdatetime as a double :) why would you need an integer?
and use them to compare in what way? is it a string or a tdatetime var?if it is a string you can use Strtodatetime
fi
var a:tdatetime;
begin
a:=Strtodatetime('10/08/20 07 10:45');
end;
and use them to compare in what way? is it a string or a tdatetime var?if it is a string you can use Strtodatetime
fi
var a:tdatetime;
begin
a:=Strtodatetime('10/08/20
end;
It's easy: int comparison = dateTimeA.CompareTo(dateTi meB);
ASKER
I found a function that gives me what I need
DateTimeToUnix()
and
UnixToDateTime()
DateTimeToUnix()
and
UnixToDateTime()
Can you not use the standard
CompareDateTime( dateTime1, dateTime2)
Which will return -1, 0 or +1 depending which is larger or if they are equal.
CompareDateTime( dateTime1, dateTime2)
Which will return -1, 0 or +1 depending which is larger or if they are equal.
system.pas defines
TDateTime = type Double;
so you can compare dates using standard operators (=, <, >) or as mike suggested use CompareDateTime (defined in DateUtils.pas).
if you really, really, really need integer use:
datetime_as_int := Round(ADateTime * SecsPerDay)
ziolko.
TDateTime = type Double;
so you can compare dates using standard operators (=, <, >) or as mike suggested use CompareDateTime (defined in DateUtils.pas).
if you really, really, really need integer use:
datetime_as_int := Round(ADateTime * SecsPerDay)
ziolko.
is this function is OK?
DateTimeToFileDate()
DateTimeToFileDate()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You do not need to convert it to an integer (which isn't even possible, only to float) to compare.