the one i thought wasn’t returning was. The problem is slightly different.
Because i am trying to find the month if the season goes between years eg Nov - apr
then in numbers Nov = 10 and Apr = 4
so it fails as apr is not bigger or equal to 12 (dec).
hmm if i use full year then it would work - 20141001 and 20150401
But i don’t want to have to change the years each time as it is irrelevant to what i am doing. and next year the now date is going to be bigger than both the above (20151201)
any thoughts? should i just pick an arbitrary 2 years and just set the now year to those?
How are those dates stored in the database? Literally as “2014-10-01” format?
If so, 2014-10-01 > 12 > 2014-12-29 is not a true logical statement, if that’s literally what’s happening. You’d need to make $now an actual date in the same format to start with.
If I’m understanding you correctly.
Another option would be to have records that are formatted without years, or something similar.
The “now” date could arbitrarily be set to the same date as your records. You could also remove years from everything, and use some sort of decimal format for dates - “5.29” or something. It depends on where you need this data. You could also store them in separate fields “month” “date” - it all depends on what you need the data for (besides this one calculation), in my mind…
[quote=“Noppy, post:5, topic:106177, full:true”]…although im now thinking i need some form of year even if they just stay the same as a reference point.
[/quote]when you’re finished thinking about it, and have made the appropriate changes to your table, please do let us know if you have any questions about it, and if you do, please do a SHOW CREATE TABLE so we can see how you’ve designed it
the table is just ‘id’,‘fish_id’,‘start_date’,‘end_date’
So i’ll try to explain my problem a bit clearer.
I have a seasonlity table so a fish could be in season between Nov and Apr.
This crosses between years, which would be fine if every year this was updated to reflect the current year, but i hadn’t planned on doing that.
If today was 1st dec 2014
This would be fine as it is between nov 2014 and apr 2015
But next year the date will be 1st dec 2015 and the date won’t fall within those dates.
I’ve tried loads of different ways i can think to do it but i think i’ve hit the wall. I think the only way i can do this is every year update the year in the start and end columns. I can just do a script to check and update the table when the year changes.