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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to find one dates exsist between two dates

Status
Not open for further replies.

prasadalone

Programmer
Aug 15, 2002
87
Dear sir

How to find one date exsist between two dates

Following is the few lines of codes


slot1=cstr(Date())+" 8:00:00 AM"
slot2=cstr(Date())+" 11:59:00 AM"
slot3=cstr(Date())+" 12:00:00 PM"
slot4=cstr(Date())+" 4:29:00 PM"

slot5=cstr(Date())+" 4:30:00 PM"
slot6=cstr(Date())+" 8:59:00 PM"
slot7=cstr(Date())+" 9:30:00 PM"
slot8=cstr(Date())+" 7:59:00 AM"

tdate= formatdatetime(now(),3)

slot1=formatdatetime(slot1,3)
slot2=formatdatetime(slot2,3)
slot3=formatdatetime(slot3,3)
slot4=formatdatetime(slot4,3)
slot5=formatdatetime(slot5,3)
slot6=formatdatetime(slot6,3)
slot7=formatdatetime(slot7,3)
slot8=formatdatetime(slot8,3)


if tdate => slot1 and slot2 <= tdate then
slot="I"
end if
if tdate => slot3 and slot4 <= tdate then
slot="II"
end if
if tdate => slot5 and slot6 <= tdate then
slot="III"
end if
if tdate => slot7 and slot8 <= tdate then
slot="IV"
end if

this code is not working
 
Store all date/time slots into array, lower values first. Then loop over array until first greater value is found, if any.

Formatdatetime() is not necessary - you compare date values (right?), not strings.

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.

[ba
 
Dear sir

I want to check whether current date time falls with in the date stored in variables

Prasad


 
I am not sure that I understand but I believe that Prasad seeks to classify a time as belonging to one of 4 periods as follows:

00:00 <= x < 08:00 --> Slot I
08:00 <= x < 12:00 --> Slot II
12:00 <= x < 16:30 --> Slot III
16:30 <= x < 21:30 --> Slot IV
21:30 <= x < 00:00 --> Slot I
 
Do you need that for complete dates/times or daily times only (as Sheco suggested)?

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.

[ba
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top