资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net比较日期大小,c语言比较日期大小

VB中怎样比较两个日期的大小

date1 = "2010-10-10 12:14"

公司主营业务:成都网站制作、成都网站设计、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出宝丰免费做网站回馈大家。

date2 = "2011-2-3"

If DateDiff("d", CDate(date1), CDate(date2)) 0 Then

MsgBox date1 "大"

Else

MsgBox date2 "大"

End If

我想在vb里对比两个变量的日期大小,应该怎么写?

可以使用DateDiff函数。

语法:DateDiff(单位,日期1,日期2)

说明:返回日期1与日期2的相差多久(天数)

以天为单位的话就设单位为"d".

VB 谁能帮我写一个判断时间日期大小的函数

re:-----------------------------------------------------------------------

Q1: 根本就没有这个函数datetime

DateDiff这个函数是vb 中比较两个日期的

Q2:我只要这么个自定义函数x 是最小值时间or日........................

比较两个自定义结构体的大小,对他们的时间和日期分别比较下就能算出来的吧,

根据你的要求只要传入两个dt,返回值类型是dtdx

public funtion DTBS(byval x as dt,optional byval y as dt=nothing) as dtdx

dim c as dtdx

if y is nothing then

c=0'等于

else

if x.日期 y.日期 then

c=4'大于

elseif x.日期 = y.日期 then

if x.时间y.时间 then

c=4'大于

elseif x.时间=y.时间

c=0'等于

else

c=2‘小于

end if

else

c=2‘小于

end if

end if

DTBS=c

end function

Ps:dtdx应当只有

大于,小于,等于

------------------------------------------------------------------------

好像时间有比较函数的吧

if datetime(datetime1)datetime(datetime2) then

如果非要用这个结构的话,貌似用循环来做比较合适吧

先写一下比较两个日期的函数

public funtion compare2(byval x as dt,byval y as dt) as boolean

dim result as boolean

if x.日期 y.日期 then

compare2=true

elseif x.日期 = y.日期 then

if x.时间y.时间 then

compare2=true

else

compare2= false

end if

else

compare2= false

end if

end function

public function dtbs(byval x as dt,byval y as dt,byval z as dt)

dim int_count as integer

int_count=3

dim arr(2) as DT

dim arr_order(2) as int

dim i as integer

dim temp as DT

arr(0)=x

arr(1)=Y

arr(2)=z

for i =0 to int_count-2

for j = 0 to int_count-2

if compare2(arr(i),arr(i+1) then

temp= arr(i)

arr(i)=arr(i+1)

arr(i+1)=arr(i)

end if

next

next

msgbox(arr(0)....................................

end function

没有测试....凭印像写的

怎样在vb中比较两个日期大小

日期比较其实直接比较2个字符串就行了

dim a as string

dim b as string

a="日期1"

b="日期2"

if ab then

msgbox("过期")

else

msgbox("没过期")

end if

VB日期比较大小问题

用datediff判断两个时间的差的正负就最简单了比如:if datediff("d",now,#2009/06/30#)0 thenabelseb=aend if


当前题目:vb.net比较日期大小,c语言比较日期大小
网页网址:http://cdkjz.cn/article/dsepjjj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220