Jump to content

Archived

This topic is now archived and is closed to further replies.

Moron

How do I get the last occurrence of a date?

Recommended Posts

Let me try this again. Our fiscal year begins on July 1, so how do I get the last occurrence of July 1? Example: 07012006. I also want it to know and post the correct year.

Share this post


Link to post
Share on other sites
Kinda vague.

Where do you want to get this last occurance? From a database? What type of database? MySQL? Can you post the current code you have? What format are these dates stored as?

Share this post


Link to post
Share on other sites
[quote author=Caesar link=topic=104236.msg415676#msg415676 date=1155579414]
Kinda vague.

Where do you want to get this last occurance? From a database? What type of database? MySQL? Can you post the current code you have? What format are these dates stored as?
[/quote]

Sorry I wasn't more clear. No, I don't mean the last occurrence with data. I mean the last time that date happened. For example, the last time it happened was July 1, [b]2006[/b]. If I had ran this program back in May or whatnot, then it would show the last occurrence as July 1, [b]2005[/b], and so on.

Share this post


Link to post
Share on other sites
You will need to store that information in order to make a reference to the last time the script was last accessed. If that is indeed your goal. Still unclear as to what it is you're asking. Regardless of what you're asking though, you will need to store data to make a reference to it, or compare it.

Share this post


Link to post
Share on other sites
[quote author=Caesar link=topic=104236.msg415687#msg415687 date=1155581146]
You will need to store that information in order to make a reference to the last time the script was last accessed. If that is indeed your goal. Still unclear as to what it is you're asking. Regardless of what you're asking though, you will need to store data to make a reference to it, or compare it.
[/quote]

Okay, I guess I'm not expressing myself very well. Sorry, but this is also a bit confusing to me. It's actually very simple. What year was the last occurrence of July 1? That's it. As of right now, the answer would be July 1, 2006. This time next year, the code will show that the last occurrence was July 1, 2007, and so on. Our fiscal year begins July 1, but I need it to be Year-aware.

Make sense?

Share this post


Link to post
Share on other sites
Err...
[code]
<?php
$curr_month = date('n');
$curr_day  = date('j');
$curr_year = date('Y');
if(($curr_month ==6 && $curr_day >= 1) || $curr_month >6){
$last = $curr_year;
}else{
$last = $curr_year - 1;
}
echo 'July 1 '.$last;
?>
[/code]

Untested, but should work

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.