GetDateTimePart Function

Action

Returns the integer value of a particular part in the specified DATETIME value.

Syntax

iValue = GetDateTimePart (datetime, partname)
Variable Description
iValue The value of the field in datetime specified by the partname constant. INTEGER.
datetime The DateTime variable from which you want a field. DATETIME.
partname A constant from the set defined for the enumerated data type. DATETIMEPART.

Notes

  • The returned value, iValue, is the integer representing the value of the part identified by partname, the DATETIMEPART constant you passed into the function.

  • One of the DATETIMEPART members is DTP_DAYOFWEEK, which specifies the day of the week of the DATETIME variable. The GetDateTimePart function numbers days of the week starting with 0 for Sunday, 1 for Monday, and so on.

  • The FormatDateTime function numbers days of the week differently than the GetDateTimePart function, using 1 for Sunday, 2 for Monday, and so on.

Example

[ ] DATETIME dt = "2000-05-30 19:42"
[ ] DATETIMEPART dateTimePart
[ ] LIST OF DATETIMEPART lsDateTimePart = {DTP_YEAR, DTP_MONTH, DTP_DAY, DTP_HOUR, DTP_MINUTE, DTP_SECOND, DTP_MICROSEC, DTP_DAYOFYEAR, DTP_DAYOFWEEK}
[-] for each dateTimePart in lsDateTimePart
	[ ] Print("{dateTimePart}:{GetDateTimePart(dt, dateTimePart)}")
[ ] 
[ ] // Result:
[ ] // DTP_YEAR: 2000
[ ] // DTP_MONTH: 5
[ ] // DTP_DAY: 30
[ ] // DTP_HOUR: 19
[ ] // DTP_MINUTE: 42
[ ] // DTP_SECOND: 0
[ ] // DTP_MICROSEC: 0
[ ] // DTP_DAYOFYEAR: 151
[ ] // DTP_DAYOFWEEK: 2