Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: User Defined Function Post Reply Post New Topic
Author Message
Tycanis
Newbie
Newbie


Joined: 18 Jul 2011
Location: United States
Online Status: Offline
Posts: 11
Quote Tycanis Replybullet Topic: User Defined Function
     Posted: 11 Feb 2013 at 1:13pm
I am trying to create a user defined function that will take a datetime field and determine which time frame the time fits into according to fifteen minute intervals.  I got this to work in Access and am now trying to do the same in Crystal Reports so that it can be published in a report on Business Objects.
 
This is what I got so far but I do not think it is going to work because it should be checking cases of dteTimeRec but when I put this in Select I get an error when checking it.  Please help.  Also I am new this being my first report in Crystal Reports and my first user defined function.
 
Function (DateTimeVar dteReceived)
TimeVar dteTimeRec;
dteTimeRec = TimeValue(dteReceived);
Select dteReceived
Case #1:00:00 AM# To #1:15:00 AM#:
"1:00A to 1:15A"
Case #1:15:00 AM# To #1:30:00 AM#:
"1:15A to 1:30A"
Case #1:30:00 AM# To #1:45:00 AM#:
"1:30A to 1:45A"
Case #1:45:00 AM# To #2:00:00 AM#:
"1:45A to 2:00A"
Case #2:00:00 AM# To #2:15:00 AM#:
"2:00A to 2:15A"
Case #2:15:00 AM# To #2:30:00 AM#:
"2:15A to 2:30A"
Case #2:30:00 AM# To #2:45:00 AM#:
"2:30A to 2:45A"
Case #2:45:00 AM# To #3:00:00 AM#:
"2:45A to 3:00A"
Case #3:00:00 AM# To #3:15:00 AM#:
"3:00A to 3:15A"
Case #3:15:00 AM# To #3:30:00 AM#:
"3:15A to 3:30A"
Case #3:30:00 AM# To #3:45:00 AM#:
"3:30A to 3:45A"
Case #3:45:00 AM# To #4:00:00 AM#:
"3:45A to 4:00A"
Case #4:00:00 AM# To #4:15:00 AM#:
"4:00A to 4:15A"
Case #4:15:00 AM# To #4:30:00 AM#:
"4:15A to 4:30A"
Case #4:30:00 AM# To #4:45:00 AM#:
"4:30A to 4:45A"
Case #4:45:00 AM# To #5:00:00 AM#:
"4:45A to 5:00A"
Case #5:00:00 AM# To #5:15:00 AM#:
"5:00A to 5:15A"
Case #5:15:00 AM# To #5:30:00 AM#:
"5:15A to 5:30A"
Case #5:30:00 AM# To #5:45:00 AM#:
"5:30A to 5:45A"
Case #5:45:00 AM# To #6:00:00 AM#:
"5:45A to 6:00A"
Case #6:00:00 AM# To #6:15:00 AM#:
"6:00A to 6:15A"
Case #6:15:00 AM# To #6:30:00 AM#:
"6:15A to 6:30A"
Case #6:30:00 AM# To #6:45:00 AM#:
"6:30A to 6:45A"
Case #6:45:00 AM# To #7:00:00 AM#:
"6:45A to 7:00A"
Case #7:00:00 AM# To #7:15:00 AM#:
"7:00A to 7:15A"
Case #7:15:00 AM# To #7:30:00 AM#:
"7:15A to 7:30A"
Case #7:30:00 AM# To #7:45:00 AM#:
"7:30A to 7:45A"
Case #7:45:00 AM# To #8:00:00 AM#:
"7:45A to 8:00A"
Default:
"After 8:00A";
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 12 Feb 2013 at 2:36am
hi

Change your case statement syntax like :

Case TIME(1,00,00) To TIME(1,15,00):
"1:00A to 1:15A"

It works.
Thanks,
Sastry
IP IP Logged
Tycanis
Newbie
Newbie


Joined: 18 Jul 2011
Location: United States
Online Status: Offline
Posts: 11
Quote Tycanis Replybullet Posted: 12 Feb 2013 at 5:22am
This does not seem to be working for me.  I am not sure the reasoning.  I made these changes and they make sense but everything is coming through as After 8:00A or the Default value.  I made a Field in the report to check and under either Time() or TimeValue() the field of interest produces the time.  This would indicate to me that there is something wrong with my user defined function?
IP IP Logged
Tycanis
Newbie
Newbie


Joined: 18 Jul 2011
Location: United States
Online Status: Offline
Posts: 11
Quote Tycanis Replybullet Posted: 12 Feb 2013 at 6:15am
Figured it out.  I got rid of the user defined function and simply put everything into a formula field with a little editing and it works perfectly.  Thanks
IP IP Logged
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