Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Date Ranges Post Reply Post New Topic
Author Message
leedo
Newbie
Newbie
Avatar

Joined: 28 Jun 2007
Location: Egypt
Online Status: Offline
Posts: 7
Quote leedo Replybullet Topic: Date Ranges
    Posted: 28 Jun 2007 at 6:35am
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)


Thanks



Edited by leedo - 28 Jun 2007 at 6:37am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 28 Jun 2007 at 11:17am
Are you doing a record selection formula? If so, just pick the field and in the condition dropdown box pick the Is Between criteria. If this isn't what you are looking for, then please post more info so we know where in the report you want this in and what its purpose is.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 28 Jun 2007 at 11:54am
You may want to look at the DatePart function in CR help. You may have to use a formula to parse out the day of week from the date , then do a compare to your range of days. Then do the same for the time and do a compare to range of times.
 
If you give it try let me know if it works.
 
Regards,
 
John W.
IP IP Logged
leedo
Newbie
Newbie
Avatar

Joined: 28 Jun 2007
Location: Egypt
Online Status: Offline
Posts: 7
Quote leedo Replybullet Posted: 30 Jun 2007 at 1:49am
Hello guys,

Here is what I ended up with:



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
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 30 Jun 2007 at 12:41pm

Thanks for sharing the formula!  While I code in VB.net, I have gotten comfortable with the Crystal syntax.

I wonder how many people use Crystal syntax vs Basic.
 
 
Thanks again for the update.
 
John W.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.014 seconds.