Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time Check

Status
Not open for further replies.

Zahir

Programmer
Sep 16, 1999
28
0
0
PK
Hi..

i want to do som time check inwhich i have aproblem when the time is like

Time from : 10:00:00 PM
Time To : 6:00:00 AM

i wana do some work in this time how i can handle this situation, co PM to PM / AM to AM is not a problem but only when AM-PM is appeared it givess prroblem .

Please i need solution urgent ..

Thanks in anticipation

Zahir
 
hi zahir,
What i understood from your question is that you want to solve the problem for 6 to 06 ? is it? try using format
format("000","a1") makes it a0001 kind.... hence look out for it. Try it for me...
 
hi zahir,
What i understood from your question is that you want to solve the problem for 6 to 06 ? is it? try using format
Format("6", "00") makes it 06 . hence look out for it. If your problem is somethign else you can write it to me.
bye
Try it for me...
 
no i need to check in between 10:00:00 PM to 06:00:00 PM
 
Have you tried :

Dim myTime as Date
Dim CompareTime as String
CompareTime = Format(myTime,"hh:mm:ss")

Otherwise remember that Date/time values can be converted to Doubles. If you do this then the integer part represents whole days since 1/1/1900 and the fractional part represents fractions of a day since midnight.

eg At 0843 in the immediate window I type

?cdbl(now)
and got this result
37465.3631712963

Let me know if this helps
 
Although its not intuitively obvious, the DateDiff function works with times and dates, and can be used to determine the difference between two times.

dim time1 as string
dim time2 as string
dim hourdiff as Long
dim mindiff as Long

time1 = "10:00:00 PM"
time2 = "6:00:00 AM"
hourdiff = DateDiff("h", time1, time2)
Debug.Print hourdiff ' -16
mindiff = DateDiff("n", time1, time2) ' Lower Case n
Debug.Print mindiff ' -960

What you will need to do is account for differences between days, which is not known given the times you provided.

BTW: That is a "n" as in November, which is used for minutes. The letter "m" as in March is used for months Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top