hi,

How do i check for time difference for eg: i have code like this

If GetServerDateTime() < Format(Now, "MM/dd/yyyy hh:mm:ss tt") Then
msgbox ("Invalid datetime")
endif

i want to make it like if the time difference is within 2 min from the current time.... the application still can allowed to next form. Is there a specific code to do this....just to check the minute difference

You need to subtract 2 minutes from the time and then compare.

See if this helps.

MsgBox(Format(Now.AddMinutes(5), "MM/dd/yyyy hh:mm:ss tt"))
        MsgBox(Format(Now.AddMinutes(-5), "MM/dd/yyyy hh:mm:ss tt"))

hi codeorder,

i have code something like this but not get the aactual understanding of it. please help me to solve this....can you modify in my code itself..thank you

If GetServerDateTime() > Format(Now, "MM/dd/yyyy hh:mm:ss tt") Then

                Dim tm1 As String = Format(Now, "MM/dd/yyyy hh:mm:ss tt")
                Dim tm2 As String = (Format(Now.AddMinutes(-2), "MM/dd/yyyy hh:mm:ss tt"))
                Dim tm3 As String = tm2 - tm1
                If tm2 < GetServerDateTime() Then

                    Debug.Print("GetServerDateTime()= " & GetServerDateTime())
                    Debug.Print("Now= " & Now)
                    MsgBox("ddd")

                    'frmPopup1.lblErrMsg.Text = GetButtonText("InvalidDateTime")
                    'frmPopup1.YesNo = False
                    'frmPopup1.QorEx = False
                    'frmPopup1.ShowDialog()
                    'Application.Exit()
   
                    End
                End If
            End If

try this .

If GetServerDateTime() < (Format(Now.AddMinutes(-2), "MM/dd/yyyy hh:mm:ss tt")) Then
msgbox ("Invalid datetime")
end if

You may need to format it a bit.

commented: don't post if you can't give proper solution +0

i need to code for this but but i still don't get the clear picture on how to do it....please guide


if my server datetime = 03/29/2011 03:12:36 and pc datetime = 03/29/2011 03:12:36 then i allow the application to proceed
if
if my server datetime = 03/29/2011 03:12:36 and pc datetime = 03/29/2011 03:14:36 then i allow the application to proceed
if
server datetime = 03/29/2011 03:12:36 and pc datetime = 03/29/2011 03:20:36 then i exit application
if
server datetime = 03/29/2011 03:12:36 and pc datetime = 03/20/2011 03:20:36 then i exit application
if
server datetime = 03/29/2011 03:12:36 and pc datetime = 03/28/2011 02:20:36 then i exit application

commented: don't post garbage here. -2

You have been supplied with enough logic by way of sample code.

Now its time for you to show effort.

Try to code the logic that you want to implement and post the code here.

hi debasisdas,

if you can't come out with the proper solution then please don't reply on my question...i send a question to get a solution which i don't understand to solve it....

commented: We don't GIVE proper solution. We give help so YOU get the proper solution -3
commented: don't show attitude here. -2

ohh.....

if you do not understand the question itself how will you get the solution ?

and you should not try to offend those who try to help you.

i don't think so i need to waste my time to answer you.

commented: why you always mis behave ? -3

its not THOSE its YOU !!! did i mention i did not understand the question. please read the the English statement correctly...

commented: stop misbehaving. -2

The only thing I did not see in this thread is:
Use the difftime() function check the time difference.


But what I do see is a lot of help given and no attempt, only attitude, from the person asking for help. Please reread this thread and try using the help given.

EXCUSE ME !!
what do u mean by this ..only attitude, from the person asking for help
i don't think so i need an advice or some other unrelated things to be posted other than a answer for my question....as this is the public forum that i can send a question's as i wish...STOP from post a nonsense thing other than a answer for my question.

commented: bad, bad ,bad attitude. -3

Some people post here looking for help. Others post to have their problems done for them.

We've given you help. 4 different suggestions and code.
You complained. You want us to write the code for you. Sorry. That's not how this public forum works.

If you want to post more information to help us understand what you don't understand, please do. But right now, I guess we don't really know what you need.

If GetServerDateTime.ToString("MM/dd/yyyy hh:mm:ss tt") < Format(Now, "MM/dd/yyyy hh:mm:ss tt") Then
msgbox ("Invalid datetime")
endif

Use like this..........
Hope it will helps u.

I am personally not clear of what GetServerDateTime returns/is/or does, but see if this helps.

Dim dtServer As DateTime = CDate(Format(GetServerDateTime, "MM/dd/yyyy hh:mm:ss tt")).AddMinutes(+2) '// server date/time.
        Dim dtUser As DateTime = CDate(Format(Now, "MM/dd/yyyy hh:mm:ss tt")) '// date/time on user p.c..
        If dtServer >= dtUser Then '// check if the server date/time +2 minutes, equals or is greater than the users p.c. time.
            MsgBox("allow")
        Else
            MsgBox("cancel")
        End If
commented: thank you so much your reply solve my problem ! +0
' set the previous date/time here
        Dim theTime As Date = New Date(2011, 3, 29, 10, 38, 4, 0)

        ' check it
        If DateDiff(DateInterval.Minute, theTime, Now) < 2 Then
            MsgBox("less than 2 minutes")
        Else
            MsgBox("whatever")
        End If

I will not post an answer for this one, because I saw enough code. What is missing here is just "a nonsense thing other than a answer".

You come to here for an answer, which is good. But the answer is not free. You need to pay with your own effort. That is a common sense, not a "nonsense". Get it?

This one should be solved now.

commented: i don't prefer a nonsence answer from you too....u got it !! +0
commented: thanks for the counter NONSENSE campaign. +9

thank you so much !! i manage to solve from the answer given.... for those who are giving nonsense reply DO STOP it...as this is not your personal web forum....this forum meant to be a public and i can ask question as i wish for.. for those who not able to give a solution then you should not reply a NONSENSE things on my thread....as i waste my bloody time to read these nonsense ....so simple like that...hope you got it!!!

commented: misbehaving idiot. -2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.