Click here to Skip to main content
12,951,971 members (64,232 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all

i wrote the below code to find the date difference

Dim var As String
        var = ds.Tables(0).Rows(0)(0)
        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

1 solution

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

Solution 1

Try switching the parameters :
mth = DateDiff(DateInterval.Month,  time, DateTime.Now)
snehasish nandy 26-Sep-12 1:43am
Got it..thanks..need one more to refresh a grid according to date..??means only day wish data it should 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
OriginalGriff 6,239
CHill60 3,490
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,880

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