dbTalk Databases Forums  

Find date of the next Saturday?

comp.databases.filemaker comp.databases.filemaker


Discuss Find date of the next Saturday? in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
dvfx
 
Posts: n/a

Default Find date of the next Saturday? - 09-17-2010 , 01:37 AM






Looked through the archives and I couldn't find anything that would
give me the date of the next Saturday.

Anyone?

(Yes, I am building heaps of reports lately :-) )

Reply With Quote
  #2  
Old   
Christoph Kaufmann
 
Posts: n/a

Default Re: Find date of the next Saturday? - 09-17-2010 , 07:21 AM






dvfx <damienvfx (AT) gmail (DOT) com> wrote:

Quote:
Looked through the archives and I couldn't find anything that would
give me the date of the next Saturday.
I used brute force when I had to find next monday.

Check the date functions - there's one that returns a number code for
the day of the week, with 1 being Sunday, 2 being Monday and 6 being
Saturday.

First, I get that code for today, then I use the case function:

If today is saturday, add 0 or 7 days to today's date, depending on your
business logic
If today is sunday, add 6 days to today's date

and so on.

Everything wrapped in a Let function of course - it makes life so much
easier.

--
http://clk.ch

Reply With Quote
  #3  
Old   
Lynn Allen
 
Posts: n/a

Default Re: Find date of the next Saturday? - 09-17-2010 , 12:02 PM



On 2010-09-16 23:37:56 -0700, dvfx <damienvfx (AT) gmail (DOT) com> said:

Quote:
Looked through the archives and I couldn't find anything that would
give me the date of the next Saturday.

Anyone?

(Yes, I am building heaps of reports lately :-) )
Always check www.briandunning.com first when you need something like
this. There are so many custom functions already there, there is always
something close, if not exact.

http://www.briandunning.com/cf/345

will give you the next date, based on a day name, from a designated
date. Easy as pi.

Lynn Allen
FM10 Certified Developer

Reply With Quote
  #4  
Old   
dvfx
 
Posts: n/a

Default Re: Find date of the next Saturday? - 09-21-2010 , 02:30 AM



On Sep 18, 1:02*am, Lynn Allen <l... (AT) semiotics (DOT) com> wrote:
Quote:
On 2010-09-16 23:37:56 -0700, dvfx <damien... (AT) gmail (DOT) com> said:

Looked through the archives and I couldn't find anything that would
give me the date of the next Saturday.

Anyone?

(Yes, I am building heaps of reports lately :-) *)

Always checkwww.briandunning.comfirst when you need something like
this. There are so many custom functions already there, there is always
something close, if not exact.

http://www.briandunning.com/cf/345

will give you *the next date, based on a day name, from a designated
date. *Easy as pi.

Lynn Allen
FM10 Certified Developer
Forgive my lack of understanding with custom functions. I've tried
several times to get this to work. I have FMP 11 Advanced, but
nothing I do when I put in that function seems to work. Could someone
actually see if they can get this to work?

Reply With Quote
  #5  
Old   
Michael Myett
 
Posts: n/a

Default Re: Find date of the next Saturday? - 09-21-2010 , 10:09 AM



On Tue, 21 Sep 2010 00:30:59 -0700 (PDT), dvfx <damienvfx (AT) gmail (DOT) com>
wrote:

Quote:
On Sep 18, 1:02*am, Lynn Allen <l... (AT) semiotics (DOT) com> wrote:
On 2010-09-16 23:37:56 -0700, dvfx <damien... (AT) gmail (DOT) com> said:

Looked through the archives and I couldn't find anything that would
give me the date of the next Saturday.

Anyone?

(Yes, I am building heaps of reports lately :-) *)

Always checkwww.briandunning.comfirst when you need something like
this. There are so many custom functions already there, there is always
something close, if not exact.

http://www.briandunning.com/cf/345

will give you *the next date, based on a day name, from a designated
date. *Easy as pi.

Lynn Allen
FM10 Certified Developer

Forgive my lack of understanding with custom functions. I've tried
several times to get this to work. I have FMP 11 Advanced, but
nothing I do when I put in that function seems to work. Could someone
actually see if they can get this to work?
I just posted one there. Give this a try.

http://www.briandunning.com/cf/1214

I also made a sample file which contains the same custom function
available for download at http://filemakerapps.biz/Last_Saturday.zip

Reply With Quote
  #6  
Old   
Lynn Allen
 
Posts: n/a

Default Re: Find date of the next Saturday? - 09-21-2010 , 10:39 AM



On 2010-09-21 00:30:59 -0700, dvfx <damienvfx (AT) gmail (DOT) com> said:

Quote:
Forgive my lack of understanding with custom functions. I've tried
several times to get this to work. I have FMP 11 Advanced, but
nothing I do when I put in that function seems to work. Could someone
actually see if they can get this to work?
Learning custom functions can be a bit tricky. The Help file will
offer some assistance, but the basics are this:

Each function will have one or more "parameters" which are necessary to
the operation of the function. For the function in question, the
important data is below---

Format:
NextDayNameDate ( theDate ; theDayName )

Parameters:
theDate = the start date (date)
theDayName = the dayName (text)

You must create the parameters yourself when you copy and paste the
custom function operational portion into the custom function dialog.
They should be named exactly as specified in the function, and you
should not change the name of the function itself, as it may call
itself in a recursive manner.

Then, when you call the custom function in a calculation field or
script step, substitute YOUR DATA for the parameters, in the order
specified.

So the calculation would look like this:

NextDayNameDate ( 1/1/2011, "Saturday" )

For that date, you can substitute any date field, so on each record,
you can find the Saturday after the date specified in the field. The
day name can be a field as well, as long as the result of the field is
a proper day name.

I hope this helps you figure it out. Custom functions are very
powerful, and the Brian Dunning site is a wonderful resource for us all.

Lynn Allen
FM 10 Certified Developer

Reply With Quote
  #7  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: Find date of the next Saturday? - 09-21-2010 , 02:56 PM



On 9/21/2010 12:30 AM, dvfx wrote:

Quote:
Forgive my lack of understanding with custom functions. I've tried
several times to get this to work. I have FMP 11 Advanced, but
nothing I do when I put in that function seems to work. Could someone
actually see if they can get this to work?

You don't even need to use them as custom functions. The one that
Michael posted can just be used as a regular calculation without being
part of a custom function. However, I think Michael's seems to find the
last Saturday of a month(?).

I just wrote this and haven't fully tested it, but it seems to work for
about a dozen different tests I just did in the data viewer:

let([
theDate = get(currentdate),
target = 7]; // Saturday is day #7

theDate - Mod ( DayOfWeek ( theDate ) - target ; 7 ) + 7
)

You may need to make adjustments to accommodate your needs. If today is
Saturday, for example, the above calc will result in NEXT Saturday
rather than today. Just depends on your needs.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg
FM Professional Solutions, Inc. Los Angeles

FileMaker Certified Developer
Associate Member, FileMaker Business Alliance

Reply With Quote
  #8  
Old   
Michael Myett
 
Posts: n/a

Default Re: Find date of the next Saturday? - 09-21-2010 , 04:29 PM



On Tue, 21 Sep 2010 12:56:02 -0700, Howard Schlossberg
<howard (AT) nospam (DOT) fmprosolutions.com> wrote:

Quote:
On 9/21/2010 12:30 AM, dvfx wrote:

Forgive my lack of understanding with custom functions. I've tried
several times to get this to work. I have FMP 11 Advanced, but
nothing I do when I put in that function seems to work. Could someone
actually see if they can get this to work?


You don't even need to use them as custom functions. The one that
Michael posted can just be used as a regular calculation without being
part of a custom function. However, I think Michael's seems to find the
last Saturday of a month(?).

I just wrote this and haven't fully tested it, but it seems to work for
about a dozen different tests I just did in the data viewer:

let([
theDate = get(currentdate),
target = 7]; // Saturday is day #7

theDate - Mod ( DayOfWeek ( theDate ) - target ; 7 ) + 7
)

You may need to make adjustments to accommodate your needs. If today is
Saturday, for example, the above calc will result in NEXT Saturday
rather than today. Just depends on your needs.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg
FM Professional Solutions, Inc. Los Angeles

FileMaker Certified Developer
Associate Member, FileMaker Business Alliance
Absolutley correct Howard, mine does the last Saturday of any selected
month. I should have read the original post more carefully.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.