[Overview][Constants][Types][Classes][Procedures and functions][Variables] |
Convert a date/time string to a TDateTimevalue.
Source position: datih.inc line 120
function StrToDateTime( |
const S: String |
):TDateTime; |
StrToDateTimeconverts the string Sto a TDateTimedate and time value. The Date must consist of 1 to three digits, separated by the DateSeparatorcharacter. If two numbers are given, they are supposed to form the day and month of the current year. If only one number is given, it is supposed to represent the day of the current month. (This is notsupported in Delphi)
The order of the digits (y/m/d, m/d/y, d/m/y) is determined from the ShortDateFormatvariable.
On error (e.g. an invalid date or invalid character), an EConvertErrorexception is raised.
|
Convert a date string to a TDateTimevalue. |
|
|
Convert a time string to a TDateTimevalue. |
|
|
Converts a TDateTimevalue to a string using a predefined format. |
Program Example20; { This program demonstrates the StrToDateTime function } Uses sysutils; Procedure TestStr (S : String); begin Writeln (S,' : ',DateTimeToStr(StrToDateTime(S))); end; Begin Writeln ('ShortDateFormat ',ShortDateFormat); TestStr(DateTimeToStr(Now)); TestStr('05-05-1999 15:50'); TestStr('5-5 13:30'); TestStr('5 1:30PM'); End.