Home  |  Delphi .net Home  |  System.Convert  |  ToDateTime Method
ToDateTime  
Method  
Converts data from one data type to a DateTime data type
Convert Class
System NameSpace
CF1.  Function ToDateTime ( Value : Boolean; ) : DateTime; Static;
CF2.  Function ToDateTime ( Value : Byte; ) : DateTime; Static;
CF3.  Function ToDateTime ( Value : Char; ) : DateTime; Static;
CF4.  Function ToDateTime ( Value : DateTime; ) : DateTime;
CF5.  Function ToDateTime ( Value : SmallInt; ) : DateTime; Static;
CF6.  Function ToDateTime ( Value : ShortInt; ) : DateTime; Static;
CF7.  Function ToDateTime ( Value : Integer; ) : DateTime; Static;
CF8.  Function ToDateTime ( Value : Int64; ) : DateTime; Static;
CF9.  Function ToDateTime ( Value : UInt64; ) : DateTime; Static;
CF10.  Function ToDateTime ( Value : Word; ) : DateTime; Static;
CF11.  Function ToDateTime ( Value : Single; ) : DateTime; Static;
CF12.  Function ToDateTime ( Value : Double; ) : DateTime; Static;
CF13.  Function ToDateTime ( Value : Decimal; ) : DateTime; Static;
CF14.  Function ToDateTime ( Value : DateTime; ) : DateTime; Static;
CF15.  Function ToDateTime ( Value : String; ) : DateTime;
CF16.  Function ToDateTime ( Value:StringValue : String; FormatProvider : IFormatProvider; ) : DateTime;
CF17.  Function ToDateTime ( Value : Object; ) : DateTime;
CF18.  Function ToDateTime ( Value:ObjectValue : Object; FormatProvider : IFormatProvider; ) : DateTime; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Attempts to transfer the value from one of the given Value data types to DateTime.
 
The optional FormatProvider parameter determines the parsing rules and is beyond the scope of this article.
Notes
An exception is thrown if the conversion fails.
Microsoft MSDN Links
System
System.Convert
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  myDate : DateTime;
  myStr  : String;

begin
  myStr  := '6/12/2004';

  myDate := System.Convert.ToDateTime(myStr);

  Console.WriteLine(myDate);

  Console.ReadLine;
end.
Show full unit code
  06/12/2004 00:00:00
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author