Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

i wrote the below code to find the date difference

VB
Dim var As String
        var = ds.Tables(0).Rows(0)(0)
        connection.Close()
        Dim time As DateTime = var
        Dim mth As Integer
        mth = DateDiff(DateInterval.Month, DateTime.Now, time)
        If mth <= 6 Then

but i am getting the "mth" value in negative..please tell me where i am wrong

the value of "time" is 1/8/2012
Posted

1 solution

Try switching the parameters :
VB
mth = DateDiff(DateInterval.Month,  time, DateTime.Now)
 
Share this answer
 
Comments
[no name] 26-Sep-12 1:43am    
Got it..thanks..need one more help..how to refresh a grid according to date..??means only day wish data it should show.it shouldn't show previous days entries..
[no name] 26-Sep-12 1:48am    
please reply..i need help in this..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900