如何从日期获得月份和年份
Date = 01/02/2012 (dd/mm/yyyy)
Run Code Online (Sandbox Code Playgroud)
从上面的日期开始,我想得到 02/2012 (mm/yyyy)
如何在vb6中编写代码
需要vb6代码帮助
您可以使用带有Date参数的Month()和Year()函数.
即Month(Now)返回月份并Year(Now)返回年份.
Dim yourDate As Date
yourDate = #01/02/2012#
Dim yourMonth As Integer
Dim yourYear As Integer
yourMonth = Month(yourDate)
yourYear = Year(yourDate)
Run Code Online (Sandbox Code Playgroud)
你可以使用Format$:
Dim formattedDate as String
Dim myDate as Date
myDate = #1/2/2012#
formattedDate = Format$(myDate, "mm/yyyy")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23514 次 |
| 最近记录: |