Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hi all

i wrote the below code to find the date difference

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 25-Sep-12 20:31pm
Code-Hunt7.1K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try switching the parameters :
mth = DateDiff(DateInterval.Month,  time, DateTime.Now)
  Permalink  
Comments
snehasish nandy at 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..
snehasish nandy at 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)

  Print Answers RSS
0 Maciej Los 184
1 Sascha Lefévre 120
2 Abhinav S 104
3 Richard MacCutchan 90
4 Sergey Alexandrovich Kryukov 84
0 Sergey Alexandrovich Kryukov 6,628
1 OriginalGriff 6,298
2 Peter Leow 2,534
3 Maciej Los 2,492
4 Abhinav S 2,378


Advertise | Privacy | Mobile
Web03 | 2.8.150414.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100