Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select data not in range

Status
Not open for further replies.

bobmorane

Technical User
Jul 2, 2002
38
FR
Hello
I have a problem when i try to select data in a certain range... here goes some part of my code :

if Month(timestamp) = Month(Now)-1
AND
DateTime(timestamp) Not in DateTime(Date(Now),Time(00,00,00)) to DateTime(Date(Now)-Date(00,01,00), Time(05,00,59))
<then display field>


Of course CR does not accept this &quot;not in&quot;, only &quot;in&quot;...
Otherwise should I try to write a code which would mean : &quot;display all fields, unless they're 'in' that range&quot; ???

If it's unclear, just tell me and i'll try to explain more
Thanks in advance
Bob

 
...NOT DateTime(timestamp) IN DateTime(Date(Now),Time(00,00,00)) to DateTime...

That catches me out sometimes too.

Naith
 
Try the syntax below, look closely at where I placed the &quot;not&quot; and the parentheses.

if Month(timestamp) = Month(Now)-1
AND
Not (DateTime(timestamp) in DateTime(Date(Now),Time(00,00,00)) to DateTime(Date(Now)-Date(00,01,00), Time(05,00,59)))
<then display field> Software Training and Support for Macola, Crystal Reports and Goldmine
251-621-8972
dgilsdorf@mchsi.com
 
ok for the &quot;not in&quot; that worked, but i have another problem with the following code (sorry for its length, but i really don't know how to fix it) :
at the *here* word, CR tells me &quot;too few arguments passed to this function&quot;

//timestamp is DateTime type
if Day(currentdatetime) = 1 then
(
if (Month(timestamp) = Month(currentdatetime) - 1
AND
Not (timestamp in DateTime(Date(currentdatetime),Time(00,00,00)) to *here* DateTime(Date(currentdatetime)-Date(00,01,00), Time(05,00,59))))
OR
(Date(timestamp) = Date(currentdatetime) AND Time(timestamp) in Time(00,00,00) to Time(05,00,59))
then
timestamp
)
else
(
if (Month(timestamp) = Month(currentdatetime)
AND
not timestamp in DateTime(01,Month(currentdatetime), Year(currentdatetime),00,00,00) to DateTime(01,Month(Now),Year(Now),05,00,59))
then
timestamp
)
Code ends here

I would be glad if someone could sort of debug this !
As usual, if it's unclear, just tell me (this time i'll give what this code _should_ do :) )
Thanks
Bob

 
What are you trying to accomplish with the -Date(00,01,00) piece of the code?

Software Training and Support for Macola, Crystal Reports and Goldmine
251-621-8972
dgilsdorf@mchsi.com
 
i thought it would do a _correct_ difference between months, including a change of year if there is a need (e.g. we are in january/2002 => the result is december/2001)
And you asked the right question, because if I erase it CR is ok too (huh... ok for this point though ;) )

In fact I could do just a month-based selection (-> current month) but the problem is that days are divided in 3 parts, 5AM to 1PM, then to 9PM, then 5AM etc... And I just can't ignore that 5 hours range of the first day of each month...

At this moment I try to find another way to manage to get the right result
 
have a look at the dateadd() function in your help file. You can add or subtract anything from seconds to years froma date/time field. I suspect you will need to use this function to accomplish what you want.

You will not have dateadd() if you are using crystal v7 or older.

Software Training and Support for Macola, Crystal Reports and Goldmine
251-621-8972
dgilsdorf@mchsi.com
 
thank you ! I use CR 8.5 Developer and I found the function
And... Here comes another problem... ;(

DateTime(01, Month(currentdatetime), Year(currentdatetime), 00, 00, 00)

That brings me the error &quot;a day number must be between 1 and the number of days in this month&quot;
I think that's because I don't use a precise month name, CR doesn't know a month called &quot;month(currentdatetime)&quot; but i don't understand why i get such an error message
 
Keep reading the help files, you just have the arguments in the wrong order. the syntax is:

Datetime(Year,Month,Day,Hour,Minite,Second)

or in your case:

DateTime(Year(CurrentDate),Month(currentdate),1,0,0,0)

In fact if you are not converned with hours, minutes and seconds, just change this to Date() and get rid of the last 3 arguments. Software Training and Support for Macola, Crystal Reports and Goldmine
251-621-8972
dgilsdorf@mchsi.com
 
hu hu hu nope LOL ! not in the french version ;-)
nevertheless trying with your syntax gives the same error too

So my boss just come to see if I had solved the problem and he told m to use 'regular' days, so that my months are real monthes, from the 1st @ midnight to the last day @ 23.59.59
Now all that I have to write is : if month(timestamp) = month(currentdatetime) //or currentdate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top