Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: DATEPART for month and day Post Reply Post New Topic
Author Message
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Topic: DATEPART for month and day
     Posted: 12 Aug 2011 at 7:50am
Can datepart evaluate both month and day
for range?
 
I do this for month
DATEPART("M",{CostCtrGrp.AdmitDate}) in datepart("m",{@STartdate}) to datepart("M",{@Enddate})
 
but want to add day of month
so If user puts in 8/1 to 9/15 gets thru 9/15  and not all of the month
 
Thanks
 


Edited by jbalbo - 12 Aug 2011 at 7:52am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Aug 2011 at 8:29am
Why not make them use a calendar? Prevents bad date strings and easier to manage
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 12 Aug 2011 at 8:31am
add a Month to the enddate and subtract 1 day.. :)

IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 12 Aug 2011 at 9:13am
little confused on the 2nd idea?
 
I'd love to use the caledar but they do not want to use years
 
here's the thing..
user puts in start day of month and start month
then end day of month and end month
 
then I get all the records between the startdate(which is month and day and I use 2001 as year) and end date(with is end month and day and 2030 as year) but I only want the "Months in the parameter..
 
so user puts is 7, and 01 as start = 07012001
and puts in 8, and 19 as end = 08192030, I want and "adminssion" date thats 0701 thru 0819 regardless of year..
 
Thx
 
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 12 Aug 2011 at 9:34am
group by year,

had list records between those months for each year.

2001
7-1 - 8-19

2002
7-1 - 8-19

Like that
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Aug 2011 at 9:51am
The problem as I see it is that they are not entering a date so using datepart is not a safe bet to apply against a string
You could use numbers but that still let's them create non valid 'dates'
You can use calendars ( date params) and ignore the year but that might confuse them as well.
If you want to go your first route do you want to include al records in any year on 9-1 to 9-15?

Table.date in date(year(table.date),month(parambegin),day(parambegin)) to date(year(table.date), month(paramend), day(paramend))
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