4
1
|
I know how to use encodedate in Delphi to encode individual YY, MM and DD into a datetime field or use encodetime to encode individual HH, SS, MM and MS into datetime field but is there a way to specify both date and time into a datetime field?
Coz with encodedate I cannot specify the time and with encodetime I cannot specify the date...
e.g. how can I set a datetime field to 2009-11-28 14:23:12.000
Please help.
Thanks.
| ||
add a comment
|
29
|
Try using the EncodeDateTime function declarated in the DateUtils unit.
See this example
Another option
The second option works because the TDatetime It is stored as a Double (
TDateTime = type Double; ), with the date as the integral part (the EncodeDate function returns the integral), and time as fractional part.
The date part of the TDateTime represents the number of days that have passed since 12/30/1899. a TDateTime can be any date through 31 Dec 9999 (decimal value 2,958,465), TDateTime values can also be negative. The decimal value -693593 corresponds to 1 Jan 0001.
see theses examples
Important Note from embarcadero site :
for addtional information you can see this link
sumber:http://stackoverflow.com/questions/1760929/how-to-encode-a-datetime-in-delphi
|
No comments:
Post a Comment