Dim ThisDay As String = Format(Now, "yyyy-MM-dd") '獲得當(dāng)前日期字符串
成都創(chuàng)新互聯(lián)專注于召陵網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供召陵?duì)I銷型網(wǎng)站建設(shè),召陵網(wǎng)站制作、召陵網(wǎng)頁(yè)設(shè)計(jì)、召陵網(wǎng)站官網(wǎng)定制、小程序開(kāi)發(fā)服務(wù),打造召陵網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供召陵網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。
Dim ThisDateTime As DateTime = Convert.ToDateTime(ThisDay) '當(dāng)前日期轉(zhuǎn)換成DateTime
Dim ThisWeekDay As Integer = ThisDateTime.DayOfWeek '獲得當(dāng)前日期是星期幾
Dim differadd As Integer = 1 - ThisWeekDay '相差的天數(shù)(星期1與當(dāng)前星期幾相差的天數(shù))
Dim MyAdd As New TimeSpan(differadd, 0, 0, 0)
Dim MyYear As Integer = Format(Now, "yyyy") '獲取當(dāng)前日期的年份
Dim MyMonth As Integer = Format(Now, "MM") '獲取當(dāng)前日期的月份
Dim MyDay As Integer = Format(Now, "dd") '獲取當(dāng)前日期是幾號(hào)
Dim MyToday As DateTime = New DateTime(MyYear, MyMonth, MyDay)
Dim Yourday As DateTime = MyToday.Add(MyAdd)
MsgBox("本周星期一的日期是:" Yourday)
不是 有 函數(shù)嘛?
now() 就是 吧
取得 后 再 分離出你所需的,分別賦值 就行了,當(dāng)然 還是 有 函數(shù)的
Dim ThisDay As String = Format(Now, "yyyy-MM-dd") '獲得當(dāng)前日期字符串
Dim ThisDateTime As DateTime = Convert.ToDateTime(ThisDay) '當(dāng)前日期轉(zhuǎn)換成DateTime
Dim ThisWeekDay As Integer = ThisDateTime.DayOfWeek '獲得當(dāng)前日期是星期幾
Dim differadd As Integer = 1 - ThisWeekDay '相差的天數(shù)(星期1與當(dāng)前星期幾相差的天數(shù))
Dim MyAdd As New TimeSpan(differadd, 0, 0, 0)
Dim MyYear As Integer = Format(Now, "yyyy") '獲取當(dāng)前日期的年份
Dim MyMonth As Integer = Format(Now, "MM") '獲取當(dāng)前日期的月份
Dim MyDay As Integer = Format(Now, "dd") '獲取當(dāng)前日期是幾號(hào)
Dim MyToday As DateTime = New DateTime(MyYear, MyMonth, MyDay)
Dim Yourday As DateTime = MyToday.Add(MyAdd)
MsgBox("本周星期一的日期是:" Yourday)