Jump to content

Date Rules


clark96

Recommended Posts

Hi Everyone,

 

I am new to FP Desktop,

I need help with dates. We are doing time cards and they want to put the names of the employees and Sundays date under it. The names are not the problem, its the different dates that I need help with. So each week the card has there name and that weeks date on it.

 

Ex. Joe Shoes

 

3/08/09 1 card

3/15/09 2 card

3/22/09 3 card

3/29/09 4 card

Thank you

Link to comment
Share on other sites

If you want to get the Sunday at the start of the current week (at composition time), you can do something like this:

 
function PreviousSunday(fromStartDate)
{
 startDate = new Date(fromStartDate || new Date());
 if (startDate.getDay())
   startDate.setDate(startDate.getDate() - startDate.getDay());
 return startDate;
}

return FormatDate(PreviousSunday(), "ld mm dd yy");

Similarly, if you're trying to get the next Sunday from the current date:

 
function NextSunday(fromStartDate)
{
 startDate = new Date(fromStartDate || new Date());
 if (startDate.getDay())
   startDate.setDate(startDate.getDate() + 7 - startDate.getDay());
 return startDate;
}

return FormatDate(NextSunday(), "ld mm dd yy");

Link to comment
Share on other sites

Thank you Dan,

Now they want to print all the dates at one time. Each person will have at least 44 different cards. When I compose my file I need Joe Sample to have 44 different cards to reflect every Sundays date, now until the end of the year.

 

Thanks Again

Jerry Tsatsos

Link to comment
Share on other sites

Thank you Dan,

Now they want to print all the dates at one time. Each person will have at least 44 different cards. When I compose my file I need Joe Sample to have 44 different cards to reflect every Sundays date, now until the end of the year.

function NextSunday(fromStartDate)
{
 startDate = new Date(fromStartDate || new Date());
 if (startDate.getDay())
   startDate.setDate(startDate.getDate() + 7 - startDate.getDay());
 return startDate;
}

var result = "";
var thisYear = new Date().getFullYear();
for (var nextSunday = NextSunday(); nextSunday.getFullYear() == thisYear; nextSunday.setDate(nextSunday.getDate() + 7))
 result += FormatDate(nextSunday, "m/d/yy") + "<br>\n";
return result;

https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...