QTP/UFT: Current Date Time Stamps and Julian-Date

”### Current Date Time Stamps
Dim currentDateTime, currentDate, currentTime, newDateYear
currentDateTime = Now
currentDate = Date
myDate = replace(currentDate,“/”,“-“)
myDay = Day(currentDate)
myMonth = Month(currentDate)
myYear = Year(currentDate)
myAbbMonth = MonthName(myMonth, true)
currentTime = Time
newDateYear = DateAdd(“yyyy”,3,currentDate)

” #### Use Date for currentDate or any date like “10/21/2011” #####
”cJulianDate = CalculateJulianDate(Date)
”msgbox cJulianDate
Function CalculateJulianDate(ByVal jDate)
    Dim jYear,jFirstDayOfYear,jDay,JulianDate
    ‘jDate = Date
    jYear = Year(jDate)
    jFirstDayOfYear = “01/01/”&jYear
    jDay = DateDiff(“d”Cdate(jFirstDayOfYear), Cdate(jDate)) + 1
    If Len(jDay)<3 Then
        jDayOnly = Right(“0” & jDay, 3)
        else
        jDayOnly = jDay
    End If
    JulianDate = (RIGHT(jYear,2))&jDayOnly
    CalculateJulianDate = JulianDate
End Function
” #### End Codify #####
 treeSelection = PbWindow(“w_Pb_frame”).PbWindow(“w_Pb_frame”).PbTreeView(“Pb_TreeView”).GetROProperty (“selection”)
serialNumber = trim(Right(treeSelection,5))  ”Last 5 digits from Right

”## If 3 digits Julian Date needed
cJulianDay = right(CalculateJulianDate(Date),3)

”## Add the All string number
addStrNumber = Code + cJulianDay + serialNumber