udfGetYear
udfGetMonth
udfGetDay
udfGetHour
udfGetMinute
udfGetSecond
udfGetQuarter
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetYear (strYmdHms)
Return Int (ItemExtract (1, strYmdHms, ":"))
; This user defined function "udfGetYear" returns the integer number of the year of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetMonth (strYmdHms)
Return Int (ItemExtract (2, strYmdHms, ":"))
; This user defined function "udfGetMonth" returns the integer number of the month of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetDay (strYmdHms)
Return Int (ItemExtract (3, strYmdHms, ":"))
; This user defined function "udfGetDay" returns the integer number of the day of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetHour (strYmdHms)
Return Int (ItemExtract (4, strYmdHms, ":"))
; This user defined function "udfGetHour" returns the integer number of the hour of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetMinute (strYmdHms)
Return Int (ItemExtract (5, strYmdHms, ":"))
; This user defined function "udfGetMinute" returns the integer number of the minute of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetSecond (strYmdHms)
Return Int (ItemExtract (6, strYmdHms, ":"))
; This user defined function "udfGetSecond" returns the integer number of the second of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetQuarter_v1 (strYmdHms)
intMonth = Int (ItemExtract (2, strYmdHms, ":"))
If intMonth < 4 Then Return 1
If intMonth < 7 Then Return 2
If intMonth < 10 Then Return 3
Return 4
; This user defined function "udfGetQuarter" returns the ordinal number of the quarter of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetQuarter_v2 (strYmdHms)
Return Int (ItemExtract (ItemExtract (2, strYmdHms, ":"), "1,1,1,2,2,2,3,3,3,4,4,4", ","))
; This user defined function "udfGetQuarter" returns the ordinal number of the quarter of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetQuarter_v3 (strYmdHms)
Return Int (ItemExtract (1 + ItemExtract (2, strYmdHms, ":") / 3, "1,2,3,4", ","))
; This user defined function "udfGetQuarter" returns the ordinal number of the quarter of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetQuarter_v4 (strYmdHms)
arrQ = Arrayize ("1,2,3,4", ",")
Return Int (arrQ[ItemExtract (2, strYmdHms, ":") / 3])
; This user defined function "udfGetQuarter" returns the ordinal number of the quarter of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetQuarter_v5 (strYmdHms)
arrDT = Arrayize (strYmdHms, ":")
arrQ = Arrayize ("1,2,3,4", ",")
Return Int (arrQ[arrDT[1] / 3])
; This user defined function "udfGetQuarter" returns the ordinal number of the quarter of the specified date.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------



; Test.

intYear = udfGetYear (TimeYmdHms ()) ; e. g. 2009.
intMonth = udfGetMonth (TimeYmdHms ()) ; e. g. 7.
intDay = udfGetDay (TimeYmdHms ()) ; e. g. 27.
intHour = udfGetHour (TimeYmdHms ()) ; e. g. 9.
intMinute = udfGetMinute (TimeYmdHms ()) ; e. g. 45.
intSecond = udfGetSecond (TimeYmdHms ()) ; e. g. 13.

intQuarter_v1 = udfGetQuarter_v1 (TimeYmdHms ()) ; e. g. 4.
intQuarter_v2 = udfGetQuarter_v2 (TimeYmdHms ()) ; e. g. 4.
intQuarter_v3 = udfGetQuarter_v3 (TimeYmdHms ()) ; e. g. 4.
intQuarter_v4 = udfGetQuarter_v4 (TimeYmdHms ()) ; e. g. 4.
intQuarter_v5 = udfGetQuarter_v5 (TimeYmdHms ()) ; e. g. 4.

Exit