Normal Topic [Solved] Programmed date range retrieve specs (Read 963 times)
drastixnz
Full Member
***
Offline


A Newbie....

Posts: 146
Location: New Zealand
Joined: Nov 29th, 2006
[Solved] Programmed date range retrieve specs
Sep 2nd, 2007 at 10:16pm
Print Post Print Post  
Imported the data in now works.


I am trying to work out where this line goes, I want to produce a report I have been reading "inside sesame nov 05" "Why Make 10 Reports When One Will Do?"

An the solotuin is what I want i have spent the last hour trying to work out how to do the programmed retrieves in the artical

Help pleasssseeee

drastixnz


"Here are some programmed retrieves for weeks,
months and years. All of them use a database field named
Sale_Date:
THIS WEEK
{ Sale_Date > @Date - @Dow(@Date) AND Sale_Date <= @Date - @Dow(@Date) +7 } "
So
« Last Edit: Sep 6th, 2007 at 10:02pm by drastixnz »  
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Programmed date range retrieve specs
Reply #1 - Sep 3rd, 2007 at 12:28am
Print Post Print Post  
I just tested the formula in Sesame Seasons sample database.  Works fine, no problem.

Here is the formula I used:
{ ShipDate > @Date - @Dow(@Date) AND ShipDate <= @Date - @Dow(@Date) +7 }
I modified it to use ShipDate vs. Sale_Date.
I went to the Retrieve screen.  Had to press F6 to expand the ShipDate element, pasted in the code, closed the expanded window, pressed F1o to retrieve.  Got the records I expected.

Two items to look at:
1.  Do you have an element named Sale_Date?  Change the name in the formula to the Date Element Name that you want to use.
2.  Do you actually have records for This Week in your database?  May need to change some dates to confirm testing OK.

Edited  ......
I just looked at the article, did not read it, but saw what Alec was doing.  I just saved the same spec above, then called the spec, worked OK.

Here are my steps:
1.  Go to Retrieve Screen
2.  Expand the Date Element, paste in the formula, close the expanded window.
3.  Open Spec Manager.
4.  Load the Retrieve Spec
5.  Click on tab to Save Spec
6.  Enter name "This Week's Shipments" (without the quotes)
7.  Beneath the name, enter "Shipments for today and next 6 days" (without the quotes)
8.  Click on button to Save
9.  Close Spec Manager.

Tested by clearing specs on Retrieve screen pressing F3
Open Spec Manager, loaded spec named "This Week's Shipments"
Saw the formula in Shipped Date, pressed F10, and correct records came up.

What are you doing?
What results are you seeing?
« Last Edit: Sep 3rd, 2007 at 6:07am by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
drastixnz
Full Member
***
Offline


A Newbie....

Posts: 146
Location: New Zealand
Joined: Nov 29th, 2006
Re: Programmed date range retrieve specs
Reply #2 - Sep 3rd, 2007 at 4:41am
Print Post Print Post  
Hi Bob thanks for the help.

I have done all what you said. but it says no date range found.

my date format is 1/9/2007, does this code have a different format that it needs.


Regards

Drastixnz
  
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Programmed date range retrieve specs
Reply #3 - Sep 3rd, 2007 at 5:27am
Print Post Print Post  
Format should not matter as long as it is a real DATE field.

Is the element BOUND to a DATE field? 
If it is a text field, it will not work. 

Are you using the Field Name, and not the Label/Element Name?

I am guessing that the 1/9/2007 you provided is just an example of format.  But that date may be this year, but it definiely is not THIS WEEK.

How many records do you get if you go to the date field and put this in as a spec?
>{@Date-7}  This should be last week's records unless you have future ship dates entered.

The formula in the article is using THIS WEEK, starting with a relative Yesterday, for the next 7 days.
Example for 09/03/2007
{ ShipDate > @Date - @Dow(@Date) AND ShipDate <= @Date - @Dow(@Date) +7 } =
{ ShipDate > 9/3/07 -  1                   AND ShipDate <= 9/3/07 - 1                    +7 }   =
{ ShipDate > 9/2/07                         AND ShipDate <= 9/9/07 } =
THIS WEEK.


« Last Edit: Sep 3rd, 2007 at 3:25pm by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
drastixnz
Full Member
***
Offline


A Newbie....

Posts: 146
Location: New Zealand
Joined: Nov 29th, 2006
Re: Programmed date range retrieve specs
Reply #4 - Sep 3rd, 2007 at 5:49am
Print Post Print Post  
Hi Bob,
Thanks for the help.

I should have been a little clearer in New Zealand our date format is dd/mm/yyyy

  
Back to top
IP Logged
 
drastixnz
Full Member
***
Offline


A Newbie....

Posts: 146
Location: New Zealand
Joined: Nov 29th, 2006
Re: Programmed date range retrieve specs
Reply #5 - Sep 3rd, 2007 at 5:53am
Print Post Print Post  
I have the following retirve specs, I have changed the shipdate to Date Completed0

This Week
{ Date Completed0 > @Date - @Dow(@Date) AND Date Completed0 <= @Date - @Dow(@Date) +7 }

This Year
{ @Year(Date Completed0) = @Year(@Date) }

Last Year
{ @Year(Date Completed0) = @Year(@Date) -1 }

When i run it i get "sorry, no recrods match date range"

Thanks once again.


drastixnz
  
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Programmed date range retrieve specs
Reply #6 - Sep 3rd, 2007 at 6:02am
Print Post Print Post  
See my last post.

Sorry, I was editing it while you were replying.  I need to stop doing that!

dd/mm vs. mm/dd does not matter.  Everything is based on @Date as a reference which uses internal date values.  See the explanation about calculation for THIS WEEK.  It means today and the next 6 days.  It is not Sun-Sat or Mon-Sun.  It is a rolling next six days plus today.

Date of 9/1 vs. 1/9 is still not THIS WEEK, it is older than today, 09/03/2007 (your format).


LAST WEEK would be this:
{ ShipDate > @Date - @Dow(@Date) -7 AND ShipDate <= @Date - @Dow(@Date) }

OR a simpler version:
{ ShipDate >= @Date -7 AND ShipDate < @Date }
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Programmed date range retrieve specs
Reply #7 - Sep 3rd, 2007 at 2:05pm
Print Post Print Post  
@drastixnz: Are all three failing?

Also, make sure you are using the underlying field names, NOT the element names. Retrieve Spec programming is one of the only places where you need the field name itself.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
drastixnz
Full Member
***
Offline


A Newbie....

Posts: 146
Location: New Zealand
Joined: Nov 29th, 2006
Re: Programmed date range retrieve specs
Reply #8 - Sep 5th, 2007 at 9:05am
Print Post Print Post  
Thanks to all, I followed all information, and imported some information and it works now thanks!!
  
Back to top
IP Logged