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")
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
Edited 5 Years Ago by swathys: n/a
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"))
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.
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 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
server datetime = 03/29/2011 03:12:36 and pc datetime = 03/29/2011 03:20:36 then i exit application
server datetime = 03/29/2011 03:12:36 and pc datetime = 03/20/2011 03:20:36 then i exit application
server datetime = 03/29/2011 03:12:36 and pc datetime = 03/28/2011 02:20:36 then i exit application
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.
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....
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.
Edited 5 Years Ago by debasisdas: typo
i don't think so i need to waste my time to answer you.
its not THOSE its YOU !!! did i mention i did not understand the question. please read the the English statement correctly...
The only thing I did not see in this thread is:
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.
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
' 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.
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!!!
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Private Sub btn_addline_Click(ByVal ...
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...