Brian Dunning's FileMaker Custom Functions

days2date

Converts the output from DayOfYear() or similar source to a date.

  Be the first to rate this function Log in to vote

belg4mit   belg4mit - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
days2date(80; 2007)
  Sample output:
3/22/2007

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Takes day of year, and converts it to a date. If you do not furnish a four-digit year, it will do it's best to get month and day correct, although these may be off by one an eighth of the time due to leap years. Day of week also cannot be determined without a complete year.

If you need to pass an actual year with fewer than four digits (and trust that localized pre-Gregorian translation will be handled properly by FileMaker), you can pass the year as a string e.g; days2date(80; "0007")

 

Comments

Dick Honing   Dick Honing, ecxs
Dec 2, 2021
Please correct me if I'm wrong, but is this not the same as Date ( 1 ; 1 ; 2007 ) +80
 
belg4mit   belg4mit
Dec 2, 2021
It depends on how much information you have, but no, it is not fully equivalent. 1) One may not always have a four-digit year at hand 2) Some years are leap years, shifting the last ten months by a day. Using a fixed year means that will be incorrect. This does its best to handle years properly, and when it recognizes that it cannot accurately peg down leap year-ness, the resulting date indicates this with a very old year. 3) With an inaccurate year, day of the week on the result will be incorrect, which is again indicated by a very old year.

I developed this because I was working with information which frequently only included a single digit year, or sometimes a year within a two-decade cycle, but wanted to peg down the day of year as best I could because the regulations an entry is subject to may change midyear.
 
belg4mit   belg4mit
Dec 2, 2021
For example, compare days2date(80; 0) with Date ( 1; 1; 0) +80. The latter gives "?" but the former "3/21/1601"
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 16 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: