VBScript - 增加变量的值
VBScript - Increasing a variable's value
我有以下内容:
firstDate = InputBox("Insert the first report's date desired to obtain", "Report Information - Start", "YYYY-MM-DD")
所以用户插入日期,比方说:2015-04-17
我正在尝试找到一种方法来增加特定位置 (day->DD) 的日期值,例如:
dateIncrease = Mid(firstDate, 9, 2)+1
我期待以上 return 18 (17+1)
如何增加日期的值?请帮忙。如果我不够清楚,请告诉我。谢谢
这就是您要查找的内容:
firstDate = "2015-04-17"
dateIncrease = DatePart("d", DateAdd("d", 1, DateValue(firstDate )))
从 @Uri 开始,您还可以使用这些语句来递增日期的任何部分
Dim firstDate As String
Dim dateIncrease As Integer
firstDate = "2015-04-17"
'Increment the day part
dateIncrease = DatePart("d", DateAdd("d", 1, DateValue(firstDate)))
'Increment the month part
dateIncrease = DatePart("m", DateAdd("m", 1, DateValue(firstDate)))
'Increment the year part
dateIncrease = DatePart("yyyy", DateAdd("yyyy", 1, DateValue(firstDate)))
我有以下内容:
firstDate = InputBox("Insert the first report's date desired to obtain", "Report Information - Start", "YYYY-MM-DD")
所以用户插入日期,比方说:2015-04-17
我正在尝试找到一种方法来增加特定位置 (day->DD) 的日期值,例如:
dateIncrease = Mid(firstDate, 9, 2)+1
我期待以上 return 18 (17+1)
如何增加日期的值?请帮忙。如果我不够清楚,请告诉我。谢谢
这就是您要查找的内容:
firstDate = "2015-04-17"
dateIncrease = DatePart("d", DateAdd("d", 1, DateValue(firstDate )))
从 @Uri 开始,您还可以使用这些语句来递增日期的任何部分
Dim firstDate As String
Dim dateIncrease As Integer
firstDate = "2015-04-17"
'Increment the day part
dateIncrease = DatePart("d", DateAdd("d", 1, DateValue(firstDate)))
'Increment the month part
dateIncrease = DatePart("m", DateAdd("m", 1, DateValue(firstDate)))
'Increment the year part
dateIncrease = DatePart("yyyy", DateAdd("yyyy", 1, DateValue(firstDate)))