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

公司主營(yíng)業(yè)務(wù):成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。創(chuàng)新互聯(lián)推出寶豐免費(fèi)做網(wǎng)站回饋大家。
date2 = "2011-2-3"
If DateDiff("d", CDate(date1), CDate(date2)) 0 Then
MsgBox date1 "大"
Else
MsgBox date2 "大"
End If
可以使用DateDiff函數(shù)。
語(yǔ)法:DateDiff(單位,日期1,日期2)
說(shuō)明:返回日期1與日期2的相差多久(天數(shù))
以天為單位的話就設(shè)單位為"d".
re:-----------------------------------------------------------------------
Q1: 根本就沒(méi)有這個(gè)函數(shù)datetime
DateDiff這個(gè)函數(shù)是vb 中比較兩個(gè)日期的
Q2:我只要這么個(gè)自定義函數(shù)x 是最小值時(shí)間or日........................
比較兩個(gè)自定義結(jié)構(gòu)體的大小,對(duì)他們的時(shí)間和日期分別比較下就能算出來(lái)的吧,
根據(jù)你的要求只要傳入兩個(gè)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.時(shí)間y.時(shí)間 then
c=4'大于
elseif x.時(shí)間=y.時(shí)間
c=0'等于
else
c=2‘小于
end if
else
c=2‘小于
end if
end if
DTBS=c
end function
Ps:dtdx應(yīng)當(dāng)只有
大于,小于,等于
------------------------------------------------------------------------
好像時(shí)間有比較函數(shù)的吧
if datetime(datetime1)datetime(datetime2) then
如果非要用這個(gè)結(jié)構(gòu)的話,貌似用循環(huán)來(lái)做比較合適吧
先寫(xiě)一下比較兩個(gè)日期的函數(shù)
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.時(shí)間y.時(shí)間 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
沒(méi)有測(cè)試....憑印像寫(xiě)的
日期比較其實(shí)直接比較2個(gè)字符串就行了
dim a as string
dim b as string
a="日期1"
b="日期2"
if ab then
msgbox("過(guò)期")
else
msgbox("沒(méi)過(guò)期")
end if
用datediff判斷兩個(gè)時(shí)間的差的正負(fù)就最簡(jiǎn)單了比如:if datediff("d",now,#2009/06/30#)0 thenabelseb=aend if
網(wǎng)站標(biāo)題:vb.net比較日期大小,c語(yǔ)言比較日期大小
文章來(lái)源:http://chinadenli.net/article27/dsepjjj.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、網(wǎng)站維護(hù)、ChatGPT、關(guān)鍵詞優(yōu)化、網(wǎng)站設(shè)計(jì)、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)