18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong> <strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong><br />

Date (and Time) Variables<br />

Date is another of <strong>VBScript</strong>’s data subtypes. The Date data subtype actually contains both date and<br />

time in<strong>for</strong>mation that can be stored in variables and constants. The Date <strong>for</strong>mat is Gregorian and the<br />

Time is local, with Day Lights Savings changes ignored unless specified in the system settings. The<br />

date subtype is a number that represents a date in the range of January 1, 100 to December 31, 9999.<br />

The following are valid ranges <strong>for</strong> the date and time fields:<br />

Second 0 to 59<br />

Minute 0 to 59<br />

Hour 0 to 23<br />

Day 0 to 31<br />

Month 1 to 12<br />

Year 100 to 9999<br />

With the date subtype, there are predefined <strong>VBScript</strong> constants that refer to the day of the week and<br />

New Year’s week. There are also Date and Time <strong>for</strong>matting constants that are used with the<br />

FormatDateTime function. In addition, there are several Date and Time functions available in <strong>VBScript</strong>.<br />

A literal date can be defined by surrounding a date/time value with the # symbol on each end.<br />

Some examples using Date and Time include:<br />

Dim CurDay, OldDay, DayDiff, HourDiff<br />

Dim MyDay, MyMonth, MyYear, RecentDay, OtherDay, MyDate<br />

OldDay = #3/27/2006 08:20:59# ‘ Set an old date<br />

CurDay = Now() ‘ reads current System time and date<br />

DayDiff = DateDiff(“d”. OldDay. CurDay) ‘ returns # days between OldDay and CurDay<br />

HourDiff = DateDiff(“h”, OldDay, CurDay) ‘ returns # hours between OldDay and CurDay<br />

MyDay = 27 ‘ specify day, month, year<br />

MyMonth = 3<br />

MyYear = 2006<br />

RecentDay = DateSerial(MyYear, MyMonth, MyDay) ‘ converts into a Date subtype variable<br />

OtherDay = DateSerial(MyYear, MyMonth-2, MyDay) ‘ you can use expressions in this<br />

function<br />

MyDate = FormatDateTime(CurDay, vbLongDate) ‘ displays a date in the long <strong>for</strong>mat,<br />

‘ uses computer’s regional settings<br />

Days of Week Constants<br />

Constant Value Description<br />

vbUseSystem 0 Use system value<br />

vbSunday 1 Sunday (Default)<br />

vbMonday 2 Monday<br />

vbTuesday 3 Tuesday<br />

vbWednesday 4 Wednesday<br />

vbThursday 5 Thursday<br />

vbFriday 6 Friday<br />

New Years Week Constants<br />

Constant Value Description<br />

vbUseSystem 0 Use system value<br />

vbFirstJan1 1 Start with the week in which January 1st occurs (default)<br />

vbFirstFourDays 2 Start with the week that has at least four days in the new year<br />

vbFirstFullWeek 3 Start with the first complete week of the new year<br />

70 <strong>InduSoft</strong>, Ltd.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!