📄 vbs97.htm
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML><HEAD><TITLE>DateSerial Function</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso8859-1">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="PRODUCT" CONTENT="Visual Basic Scripting Edition">
<META NAME="TECHNOLOGY" CONTENT="SCRIPTING">
<META NAME="CATEGORY" CONTENT="Language Reference">
<META NAME="Keywords" CONTENT="DateSerial function,dates converting,dates"><META NAME="Description" CONTENT="DateSerial Function"></HEAD><BODY BGCOLOR=FFFFFF LINK=#0033CC>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->
<FONT FACE="Verdana, Arial, Helvetica" SIZE=2>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR VALIGN=TOP><TD WIDTH=360>
<FONT SIZE=1 COLOR=#660033>Microsoft® Visual Basic® Scripting Edition</FONT><BR>
<FONT SIZE=5 COLOR=#660033><B>DateSerial Function</B></FONT>
</TD>
<TD ALIGN=RIGHT>
<FONT SIZE=2> <A HREF="vbstoc.htm">Language Reference</A> <BR>
<A HREF="vbs16.htm">Version 1</A> <P></FONT>
<p>
</TD></TR>
</TABLE>
<FONT SIZE=2><P>
<A HREF="vbs98.htm">See Also</A></FONT>
<HR noshade SIZE=1>
<H5>Description</H5>
<BLOCKQUOTE>Returns a <b>Variant</b> of subtype <b>Date</b> for a specified year, month, and day.</BLOCKQUOTE>
<H5>Syntax</H5>
<BLOCKQUOTE><b>DateSerial(</b><i>year</i><b>, </b><i>month</i><b>, </b><i>day</i><b>)</b><P>
The <b>DateSerial</b> function syntax has these arguments:<P>
<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>Part</b></FONT></TD>
<TD><FONT SIZE=2><b>Description</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>year</i></FONT></TD>
<TD><FONT SIZE=2>Number between 100 and 9999, inclusive, or a <A HREF="vbs0.htm#defNumericExpression">numeric expression</A>.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>month</i></FONT></TD>
<TD><FONT SIZE=2>Any numeric expression.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>day</i></FONT></TD>
<TD><FONT SIZE=2>Any numeric expression.</FONT></TD></TR>
</TABLE></BLOCKQUOTE>
<H5>Remarks</H5>
<BLOCKQUOTE>To specify a date, such as December 31, 1991, the range of numbers for each <b>DateSerial</b> argument should be in the accepted range for the unit; that is, 1–31 for days and 1–12 for months. However, you can also specify relative dates for each argument using any numeric expression that represents some number of days, months, or years before or after a certain date.<P>
The following example uses numeric expressions instead of absolute date numbers. Here the <b>DateSerial</b> function returns a date that is the day before the first day (1 – 1) of two months before August (8 – 2) of 10 years before 1990 (1990 – 10); in other words, May 31, 1980.<P>
<BLOCKQUOTE><PRE><FONT FACE="Courier New" SIZE=3 COLOR="#FF0000">DateSerial(</FONT>1990 - 10<FONT COLOR="#FF0000">,</FONT> 8 - 2<FONT COLOR="#FF0000">,</FONT> 1 - 1<FONT COLOR="#FF0000">)</FONT>
</PRE></BLOCKQUOTE>
For the <i>year</i> argument, values between 0 and 99, inclusive, are interpreted as the years 1900–1999. For all other <i>year</i> arguments, use a complete four-digit year (for example, 1800).<P>
When any argument exceeds the accepted range for that argument, it increments to the next larger unit as appropriate. For example, if you specify 35 days, it is evaluated as one month and some number of days, depending on where in the year it is applied. However, if any single argument is outside the range -32,768 to 32,767, or if the date specified by the three arguments, either directly or by expression, falls outside the acceptable range of dates, an error occurs.</BLOCKQUOTE>
<hr noshade size=1>
<p align=center><em><a href="../../common/colegal.htm">© 1997 by Microsoft Corporation. All rights reserved.</a></em></p>
</FONT></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -