Wednesday, March 21, 2012

DateTime Ranges

Hi..
I am facing a problem trying to determine whether a point in tie falls within a specific date and time range.
Here is an example..
Is 7/20/2007 1:23:45PM in the range between (Thursday 8:00 PM) To (Sunday 7:59 AM)
ThanksI've not got Crystal on this PC, so excuse any errors, but I'd expect you could do something like

numbervar d := dayofweek({date}); //or whatever the 'get day' function is!
timevar t := ctime({date}); //Get just the time part

//return whether between Thursday 8pm and Sunday 8pm
(d = CrThursday and t >= ctime(20, 0, 0))
or d = CrFriday
or d = CrSaturday
or (d = CrSunday and t < ctime(20, 0, 0))|||Thanks my friend,

I used your CRsyntax and converted it to Basic as follows:

Dim d As number
Dim t AS time

d= dayofweek(currentdatetime)
t= ctime(currentdatetime)

'return whether between Thursday 8pm and Sunday 8pm
IF (d = CrThursday and t >= ctime(20, 0, 0)) or d = CrFriday or d = CrSaturday or (d = CrSunday and t < ctime(8, 0, 0)) THEN
FORMULA= "Code if True"
Else
FORMULA= "Code if False"
END IF

No comments:

Post a Comment