Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating timestamp from a date 1

Status
Not open for further replies.

eurob

Programmer
Jan 25, 2004
13
US
In UNIX to obtain a timestamp from a date is pretty easy, I wonder if there is a script in vbscript to do the same. I would like to have "1/17/2004 6:01:48 PM" as an input parameter and as output the unique timestamp.

Thank you,

Robert
 
Well it sort of depends on what you mean by "timestamp" doesn't it?

For most COM/ActiveX purposes and many other places in Windows the vbDate type is used for this:

Dim dtStamp

dtStamp = CDate("1/17/2004 6:01:48 PM")

That's the basic idea at least, though "display date" strings like the one CDate converts are dependent on locale settings. For example is "2/3/2004" February 3rd or March 2nd?

For more control you can use DateSerial( ) or TimeSerial( ) to convert date and time component values into vbDate values.

The vbDate is implemented as a Double, an 8-byte floating-point value internally.
 
i just like to have a number back, like 3467467833. Every timestamp should have unique number.

 
To get the unique number related to a DateTime, use the CDbl function:
Code:
TimeStamp=CDbl(CDate(DateTime))
The integral part represents the date
The fractional part represents the time

Hope This Help
PH.
 
That is exactly what I needed.

Thanx a lot!

Robert
 
I'd like to know if it possible to test a text file for empty. I use this:

set inlees = fsoObject.OpenTextFile(textfile , 1)
strBuffer = textfile .ReadAll

which works fine if the textfile contains characters, but when the file is empty I get
Microsoft VBScript
runtime (0x800A003E)
Input past end of file, because the file is empty.

Appreciate your help,

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top