Many times we require unique names or id for creating file names....
I prefer creating unique names by using month, date, year, hour, minute and second (Oct_27_2009_09_04_53).
This will help us to track when it is created, easily readable format.
You can further add tags to classify the names into different types (QTP_Oct_27_2009_09_04_53).
Attaching the function to generate ids as stated above.
Function funGetTimeStamp()
sDateTIme = Now()
iDate = Datepart("d",sDateTime)
iLen = Len(iDate)
If iLen = 1 Then
iDate = "0" & iDate
End If
sMonth= mid(MonthName(Datepart("m",sDateTime)),1,3)
iYear = Datepart("yyyy",sDateTime)
iHour = Datepart("h",sDateTime)
iLen = Len(iHour)
If iLen = 1 Then
iHour = "0" & iHour
End If
iMinute = Datepart("n",sDateTime)
iLen = Len(iMinute)
If iLen = 1 Then
iMinute = "0" & iMinute
End If
iSec = Datepart("s",sDateTime)
iLen = Len(iSec)
If iLen = 1 Then
iSec = "0" & iSec
End If
funGetTimeStamp = sMonth & "_" & iDate & "_" & iYear & "_" & iHour & "_" & iMinute & "_" & iSec
End Function
-----
No comments:
Post a Comment