例如20060312变成日期型的2006-03-12。还有如何比较=<当前日期?
解决方案 »
- VB6.0 mshflexgrid问题请高手解答! 输入表格使用TEXTBOX+mshflexgrid完成。
- VB的排名居然比C#和dephi高 真有点不敢相信
- vb.net中 dim datetimepicker1 as new datetimepicker 提示未定义类型,????
- 怎么判断光驱是dvd还是cd-rom
- 请问activex控件的activex属性
- 谁能提供一个用VB编出天网那样的程序的源代啊
- 如何使得MDI窗口的子窗口成为模态窗口?
- 用vb程序存取web库(.mdb)的方法!请大家讨论,提供代码,up有分!
- datagrid的问题!!!! 高手请进。。。。。。
- 用VB的一帮傻鸟,问你们个问题!
- [VB]如何知道XP系统是HOME还是PRO
- 关于软件注册的问题??
__________________________________
strDate = left(20060312,4) & "-" & mid(20060312,5,2) & "-" & right(20060312,2)还有如何比较=<当前日期?
____________________________________
多种方法比较:
1、if CLng(CDate(strDate))<= CLng(Now) then
2、if strDate <= Now then
3、if DateDiff("d",Now,strDate)<=0 then
Dim newDate As String
'1
newDate = Mid$("20060312", 1, 4)
newDate = newDate & "-" & Mid$("20060312", 5, 2)
newDate = newDate & "-" & Mid$("20060312", 7, 2)
Debug.Print newDate
'2
If CDate(newDate) <= Date Then
Debug.Print "<="
Else
Debug.Print ">"
End If
End Sub
Private Sub Command1_Click()
Dim strDate As String
Dim strTemp As String
Dim DtmDate As Date
strDate = "20051201"
strTemp = Left(strDate, 4) & "-" & Format(Mid(strDate, 5, 2), "00") & "-" & Right(strDate, 2)
If CDate(strTemp) > Now Then
Debug.Print "大过现在日期"
ElseIf CDate(strTemp) = Format(Now, "yyyy-m-dd") Then
Debug.Print "现在日期"
Else
Debug.Print "已经过起日期"
End If
End Sub
d = 20030623
d = Format(d, "####-##-##")
Print DateDiff("d", d, Date) '与当前日期差(天数)