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>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong> <strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong><br />

vbFriday 6 Friday<br />

vbSaturday 7 Saturday<br />

The firstweekofyear argument can have the following values:<br />

Constant Value Description<br />

vbUseSystem 0 Use National Language Support (NLS) API setting<br />

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

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

new year<br />

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

Remarks You can use the DatePart function to evaluate a date and return a specific interval of time. For<br />

example, you might use DatePart to calculate the day of the week or the current hour. The<br />

firstdayofweek argument affects calculations that use the "w" and "ww" interval symbols.<br />

If date is a date literal, the specified year becomes a permanent part of that date. However, if date<br />

is enclosed in quotation marks (" "), and you omit the year, the current year is inserted in your<br />

code each time the date expression is evaluated. This makes it possible to write code that can be<br />

used in different years.<br />

See Also DateAdd, DateDiff<br />

Example This example takes a date and, using the DatePart function, displays the quarter of the year in<br />

which it occurs.<br />

Function GetQuarter(TheDate)<br />

GetQuarter = DatePart("q", TheDate)<br />

End Function<br />

DateSerial<br />

Description Returns a Variant of subtype Date <strong>for</strong> a specified year, month, and day<br />

Usage dateVal = DateSerial(year, month, day)<br />

Arguments year<br />

Any numeric value or expression that evaluates to a number between 100 and 9999<br />

month<br />

Any numeric value or expression that evaluates to a number between 1 and 12<br />

day<br />

Any numeric value or expression that evaluates to a number between 1 and 31<br />

Return A date value<br />

Remarks To specify a date, such as December 31, 1991, the range of numbers <strong>for</strong> each DateSerial<br />

argument should be in the accepted range <strong>for</strong> the unit; that is, 1–31 <strong>for</strong> days and 1–12 <strong>for</strong> months.<br />

However, you can also specify relative dates <strong>for</strong> each argument using any numeric expression<br />

that represents some number of days, months, or years be<strong>for</strong>e or after a certain date. For the<br />

year argument, values between 0 and 99, inclusive, are interpreted as the years 1900–1999. For<br />

all other year arguments, use a complete four-digit year (<strong>for</strong> example, 1800).<br />

When any argument exceeds the accepted range <strong>for</strong> that argument, it increments to the next<br />

larger unit as appropriate. For example, if you specify 35 days, it is evaluated as one month and<br />

some number of days, depending on where in the year it is applied. The same is true <strong>for</strong> negative<br />

values and the value 0, but instead of incrementing, the next larger unit is decremented. However,<br />

if any single argument is outside the range -32,768 to 32,767, or if the date specified by the three<br />

arguments, either directly or by expression, falls outside the acceptable range of dates, an error<br />

occurs.<br />

See Also Date, DateValue, Day, Month, Now, TimeSerial, TimeValue, Weekday, Year<br />

Example The following example uses numeric expressions instead of absolute date numbers. Here the<br />

DateSerial function returns a date that is the day be<strong>for</strong>e the first day (1 – 1) of two months be<strong>for</strong>e<br />

August (8 – 2) of 10 years be<strong>for</strong>e 1990 (1990 – 10); in other words, May 31, 1980.<br />

Dim MyDate1, MyDate2<br />

MyDate1 = DateSerial(1970, 1, 1) ' Returns January 1, 1970.<br />

MyDate2 = DateSerial(1990 - 10, 8 - 2, 1 - 1) ' Returns May 31, 1980.<br />

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

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

Saved successfully!

Ooh no, something went wrong!