Print Page | Close Window

Date Ranges

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=940
Printed Date: 02 May 2025 at 12:26am


Topic: Date Ranges
Posted By: leedo
Subject: Date Ranges
Date 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




Replies:
Posted By: BrianBischof
Date 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>


Posted By: jkwrpc
Date 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.
http://www.CustomReportWriters.net - www.CustomReportWriters.net


Posted By: leedo
Date 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


Posted By: jkwrpc
Date 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.
http://www.CustomReportWriters.net - www.CustomReportWriters.net



Print Page | Close Window