user2737291
user2737291

Reputation: 1

How to find a date and time stamp in a file using VBscript?

I have an online temperature logger that publishes the date and time of last measurement in a file.

I need to find the date and time stamp in the html file using VBscript, and then check if it's older then 2 hours comparing to current time.

Example date format: 12.04.2013 16:45

Upvotes: 0

Views: 1343

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200233

You could extract the timestamp with a regular expression

\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}

However, due to the characteristics of HTML this is prone to error (line-wrapping, inline tags, …), so a better approach would be to extract the date from the HTML using DOM methods (e.g. getElementsByTagName().

Once you have the date string, you can use the DateDiff function to calculate the difference to the current timestamp:

DateDiff("h", datestring, Now)

Upvotes: 1

Related Questions