Click here to Skip to main content
12,350,134 members (26,559 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB 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 19: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 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2016
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