DateAndTime.Day 方法
傳回 1 到 31 的 Integer 值,表示月中的日。
命名空間: Microsoft.VisualBasic
組件: Microsoft.VisualBasic (在 microsoft.visualbasic.dll 中)
語法
'宣告
Public Shared Function Day ( _
DateValue As DateTime _
) As Integer
'用途
Dim DateValue As DateTime
Dim returnValue As Integer
returnValue = DateAndTime.Day(DateValue)
public static int Day (
DateTime DateValue
)
public:
static int Day (
DateTime DateValue
)
public static int Day (
DateTime DateValue
)
public static function Day (
DateValue : DateTime
) : int
參數
- DateValue
必要項。您想從中取出日期的 Date 值。
傳回值
傳回 1 到 31 的 Integer 值,表示月中的日。
備註
如需詳細資訊,請參閱 Visual Basic 的主題 Day 函式 (Visual Basic)。
如果您使用 Day 函式,您必須以 Microsoft.VisualBasic 命名空間來限定它,因為 System.Windows.Forms 命名空間會將 Day 定義為列舉型別。下列範例將示範限定 Day
會如何解決此模稜兩可 (Ambiguity) 的情況:
Dim thisDay As Integer = Microsoft.VisualBasic.DateAndTime.Day(Now)
您也可以藉由呼叫 DatePart 以及為 Interval 引數指定 DateInterval.Day
,取得月中的日。
範例
下列範例會使用 Day 函式,從指定之日期取得月中的日。在開發環境中會使用您程式碼中的地區設定,以標準簡短格式表示日期常值 (例如 "02/12/1969")。
Dim oldDate As Date
Dim oldDay As Integer
' Assign a date using standard short format.
oldDate = #2/12/1969#
oldDay = Microsoft.VisualBasic.DateAndTime.Day(oldDate)
' oldDay now contains 12.
Day
會加以限定,好與 System.Windows.Forms.Day 列舉型別有所區別。
平台
Windows 98、 Windows 2000 SP4、 Windows CE、 Windows Millennium Edition、 Windows Mobile for Pocket PC、 Windows Mobile for Smartphone、 Windows Server 2003、 Windows XP Media Center Edition、 Windows XP Professional x64 Edition、 Windows XP SP2、 Windows XP Starter Edition
.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
版本資訊
.NET Framework
支援版本:2.0、1.1、1.0
.NET Compact Framework
支援版本:2.0、1.0
請參閱
參考
DateAndTime 類別
DateAndTime 成員
Microsoft.VisualBasic 命名空間
DateTime
ArgumentException
ArgumentOutOfRangeException
其他資源
Day 函式 (Visual Basic)
DatePart 函式 (Visual Basic)
Month 函式 (Visual Basic)
Now 屬性
Weekday 函式 (Visual Basic)
Year 函式 (Visual Basic)