取得日期部分的函数有吗?
vb吧
全部回复
仅看楼主
level 7
tzchf 楼主
比如取得now()的日期部分,2024-12-17。竟然没找到这样的函数。
2024年12月17日 01点12分 1
level 11
datepart自己拼接一下
Dim currentDate As Date = Now
Dim year As Integer = DatePart("yyyy", currentDate)
Dim month As Integer = DatePart("m", currentDate)
Dim day As Integer = DatePart("d", currentDate)
Console.WriteLine( year & "-" & month & "-" & day)
2024年12月17日 05点12分 3
level 15
Int[滑稽]
其实日期型就是Double型,整数部分是日期,小数部分是时间,所以取整即可获得日期
2024年12月17日 11点12分 4
level 12
我记得 date()不就是日期部分嘛。time()是时间部分 now是日期时间
2024年12月18日 05点12分 5
楼主的意思应该是给定任意一个日期时间,取出它的日期部分,Now只是个例子
2024年12月18日 05点12分
@初音✨七奈 那是我理解错了
2024年12月18日 05点12分
@初音✨七奈 [大拇指]明白人
2024年12月19日 02点12分
level 1
cdate(int(任意日期时间))
2024年12月19日 12点12分 6
cdate写了也没关系,编译时VB6是不会增加额外代码的,因为已经是date类型不会再进行转换,或许这样写方便自己理解
2024年12月20日 02点12分
无需CDate,Int不会进行类型转换,进去的是Date型,出来的还是Date型
2024年12月19日 12点12分
level 1
Text1.Text = Minute(Time)
Text2.Text = Hour(Time)
Text3.Text = Second(Time)
Text4.Text = Year(Date)
Text5.Text = Month(Date)
Text6.Text = Day(Date)
2025年08月21日 13点08分 7
level 6
a=format(now,"YYYYMMDD")
2025年09月09日 12点09分 9
1