Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Day of Year
- This topic has 9 replies, 3 voices, and was last updated 2 years, 3 months ago by
Brendan.
-
AuthorPosts
-
January 18, 2023 at 5:02 PM #48691
Glen ForisterParticipantDateCollected
I’m interested in obtaining the day of the year (1 to 365).
To do that I see how to insert another date field from the “Edit Formula” screen.
The “Date Collected” in the pic attached.The problem is I don’t know how to get the difference (IN DAYS):
– from Date which might be any of the last few years or future year
and
– Jan 1 of that year (or any year – not worried about leap year).My attached pic shows in that col (Day of Yr) the calculated days in text, but that got there from exporting out of another database program where it was calculated. But, future additions need to be calculated.
Any help? I hope it isn’t a program script. So far I haven’t had any luck with that solution on another Form.
Thanks.
-
This topic was modified 2 years, 3 months ago by
Glen Forister.
-
This topic was modified 2 years, 3 months ago by
Glen Forister.
Attachments:
You must be logged in to view attached files.January 18, 2023 at 7:03 PM #48695
Daniel LeuParticipantWell, my first thought was a Javascript script… ;-) But then I wondered if the calculation field might do the trick. Yes, and here is the solution:
DAYS(NEWDATE(DATE([Date day Collect];"yyyy");1;0;0;0;1;0;0;0);[Date day Collect])+1
It looks complex but it isn’t:
1)
DATE([Date day Collect];"yyyy")
extracts the year from yourDate day Collect
field. The square brackets are only an optical indicator.
2)NEWDATE(...)
creates the date for January 1st of yourDate day Collect
year.
3)DAYS()
calculates the days between two dates, theJanuar 1st Date day Collect
andDate day Collect
.
Then it’s just adding 1 to get the result. The return value isnumber
.Attached is the formula in my editor. I used your rain collection data where
date
equalsDate day Collect
in your graphic. I did this on my desktop.Here is the link to the calculation field documentation: https://www.tapforms.com/help-mac/5.3/en/topic/calculation.
Have fun!
-
This reply was modified 2 years, 3 months ago by
Daniel Leu.
-
This reply was modified 2 years, 3 months ago by
Daniel Leu.
Attachments:
You must be logged in to view attached files.January 18, 2023 at 9:20 PM #48706
BrendanKeymasterIf all you want is the day number of the year, you can use the
DATE()
function with the appropriate pattern to get that value.DATE([Date day collect]; "D")
The
D
will generate the day of the year for the specified date.For a list of date format patterns you can use, see this page:
http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
There’s also a link to this in the online user manual in the Calculations topic.
January 19, 2023 at 8:51 AM #48720
Daniel LeuParticipantAhh… so much easier!
January 19, 2023 at 10:00 AM #48721
Glen ForisterParticipantThanks guys. Nice.
January 19, 2023 at 10:33 AM #48722
Glen ForisterParticipantWell, Nice try, but no success.
All the formula DATE([Date day collect]; “D”) did was to delete all the data I had in that colum and all is blank.
Refresh again and again, quitting TF, starting TF, Refresh again, and the “Day of Yr” col is blank. – see attached pic with blank fields in the background.
What am I doing wrong???Attachments:
You must be logged in to view attached files.January 19, 2023 at 8:13 PM #48733
BrendanKeymasterSet the Result Type to
Text
. Because theDate()
function returns a String, not a Number.January 19, 2023 at 8:14 PM #48734
BrendanKeymasterIf you need the result to be a number you can add the
STR2NUM()
function around it to do the conversion for you if you need to use that result in some sort of other numeric calculation.January 20, 2023 at 1:51 PM #48747
Glen ForisterParticipantThat’s great.
I forgot about numbers vs strings. I chose the STR2NUM so I won’t forget it isn’t a number and try to do some chart or other calc on it. Thanks for the hint. It works.But, I can’t find any help for charts. When I try to chart Date (x axis) and another field of numbers, I get a blank chart.
January 20, 2023 at 3:05 PM #48753
BrendanKeymasterI’ve replied to your Charts question in your other post.
-
This topic was modified 2 years, 3 months ago by
-
AuthorPosts
You must be logged in to reply to this topic.