Professional Documents
Culture Documents
Subject:
11
Information Technology
Version:
Topic:
Beta
Date and Time
Videos
The following functions are used to obtain the computer system’s current date and time:
Function example Description
var dtTemp : TDateTime ; Declaration of a TDateTime variable.
dtTemp := Date ; Date function returns the current date, but the
time is recorded as the start of the day (00:00).
dtTemp := Time ; Time function returns the current time, but the
date is recorded as 1988/12/30.
dtTemp := Now ; Now function returns the current date and
current time.
1
Mr Long Grade:
Subject:
11
Information Technology
Version:
Topic:
Beta
Date and Time
Videos
• The EncodeDate functions accepts integer values for the year, month and day and
returns a date with those values. There are also an EncodeTime and EncodeDateTime
functions that take the relevant integer values to return a TTime and TDateTime value,
respectively.
Function example Description
dTemp will contain the TDate value of
dTemp := EncodeDate ( 2020 , 1, 14 ) ;
2020/01/14.
Function example
dtTemp := Now ;
sCurrent := FormatDateTime ( ‘dd mmm yyyy – hh:nn.ss’ , dtTemp ) ;
Description
A possible example of sCurrent’s string value could be:
21 Nov 2020 – 11:35.41
2
Mr Long Grade:
Subject:
11
Information Technology
Version:
Topic:
Beta
Date and Time
Videos
isLeapYear function
• The isLeapYear Boolean function accepts an integer representing a year and
returns a true of that year is a leap year and false if it is not a leap year.
Function example
iYear := 2020 ;
if isLeapYear ( iYear ) = true then
showmessage(‘2020 was a leap year’)
else showmessage(‘2020 was NOT a leap year’) ;
3
Mr Long Grade:
Subject:
11
Information Technology
Version:
Topic:
Beta
Date and Time
Videos
TDateTimePicker component
• The TDateTimePicker component is best used for input and output of a date or time
and can be found on the Win32 tab of the Tool Palette.
NOTE: The examples below will refer to a TDateTimePicker with name dtpInput.
• The component can only be used to display or allow the input of either a date or a
time.
When the component is used for a date. When the component is used for a time.
Properties Description
Date
The Date property contains the date indicated in
Example:
the component.
dtpInput.Date := StrToDate(‘2020/10/20’) ;
The DateFormat property is either dfShort
DateFormat
(2020/10/20) or dfLong (10 October 2020)
MaxDate and MinDate properties contain the
MaxDate and MinDate range of possible dates that can be stored or
selected in the component.
The Kind property is either dtkDate if the
component must be used to store or select dates
Kind
and dtkTime if the component must be used to
store or select times.
Time
The Time property contains the time indicated in
Example:
the component.
dtpInput.Time := StrToTime (’10:55:45’) ;
Additional Links:
• Youtube video playlist:
https://www.youtube.com/watch?v=NpmiL7zaUvU&list=PLxAS51iVMjv92yR95B2H5ZiR2y1yijglM
• Google drive resource activities:
https://tinyurl.com/MLE-G11IT-DateAndTime
youtube.com/user/MrLongEducation