time

I am getting an error. I want to check to see if it more than 30 day.

                Dim TmpClosedDated As Date = "02/1/08"
                    Dim myDifTime As TimeSpan

                    Dim DifTime As String

                    myDifTime = DateTime.Now.ToString("MM/dd/yy") - TmpClosedDated   < ---- here

                    If myDifTime.TotalDays > 30 Then
                  
                 ' do whatever

                    End If
VBdotnet2005Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
Why don't you use:

Dim diff As Long = DateDiff(DateInterval.Day, TmpClosedDated , DateTime.Now.Date)
0
VBdotnet2005Author Commented:
What is DateDiff?
0
Jorge PaulinoIT Pro/DeveloperCommented:
Well returns the number of intervals between two dates. Since you whant to check if the difference is bigger then 30 you can use that. You can read more in http://msdn2.microsoft.com/en-us/library/xhtyw595.aspx

Dim diff As Long = DateDiff(DateInterval.Day, TmpClosedDated , DateTime.Now.Date)
If diff > 30 Then
 ' Your code
End If
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
Just do:

        Dim TmpClosedDated As Date = "02/1/08"
        If DateTime.Now.Subtract(TmpClosedDated).TotalDays > 30 Then

        End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.