How make a flowchart that would input a numeric day (1-31 only) and output the day of the week the day falls - flowchart

December 1, 2005 falls on a Thursday. Make a program that would input a numeric day
(1-31 only) and output the day of the week the day falls. For example, if 18 is entered
for the day, the program must display “SUNDAY”, if 20 was entered, “TUESDAY” must
be displayed and so on.

Related

How to use the EOMONTH DAX to get the last date of iso month?

ISO months start and end at various dates. Not necessarily 1st/31st.
How to use the EOMONTH DAX to get the last date of iso month?
DAX can handle everything that follows a certain logic.
In your example Jan is week 1-4, Feb is 5-8 and Mar is probably 9-12. But April has to be 13-17 (5 weeks), which ends on Apr-30? After all 52 weeks divided by 4 is 13 not 12. So some "months" have to have 5 weeks instead of 4.
I'm afraid EOMONTH is not familiar with your calendar preferences as long as they not defined in any ISO regulation.
However, as mentioned above, it's possible to find the first Monday and last Sunday within a month using DAX, but not with the EOMONTH function.

Scheduling events by the week of the month, COLDFUSION

I'm trying to create a function, in Coldfusion, that will create an event by the Week of the Month, rather than by the Day of the Month.
An example would be that the event should be scheduled every 2nd week of a month, rather than the 2nd Tuesday of a month.
However, I've come across the problem that months can have anywhere from 4 to 6 weeks, and if someone scheduled an event on the 5th or 6th week of the month, it wouldn't repeat in the months that don't have 5 or 6 weeks.
I'm at a bit of a loss as to how to approach the problem, so any brainstorming advice would be greatly appreciated.
You'll need to find the lowest common denominator and that is February. February has 28 days when not leap year. A week has 7 days and 4 x 7 = 28 so that means you can not provide a function that reliably allows for scheduling on week 5 (or 6, 7, 8, etc) of every month. One work around would be that if there is no logical day for the scheduled week that month then run the task on the final day of the month or the first day of the following. On the last day for example you can check for any tasks scheduled later in the month that can not be run and then run them.

Number of sundays between two dates?

I am having problems with finding the number of sundays between two dates. I tried to use the intck () function to count number of weeks between two dates and since week in SAS starts on a Sunday I thought that was the right way. However now I am not so sure.
My dates go from 2007QI to 2013QII. I want to know the number of sundays in each quarter, so I have to look at the number of sundays between current quarter and previous (that is this date and lag (date)). When I use the intck() function I get 13 as the number of weeks in each quarter (except for one where I get 14).. i am not sure whether it is correct to assume that there are 13 sundays in each quarter?
intck is the correct function, but I would use weekday as the time interval. Ordinarily this assumes a 5 day working week, with Saturday and Sunday as weekends, but you can tweak it to use a 1 day working week, with Monday - Saturday as weekends (i.e. just count the number of Sundays).
data _null_;
format a b date9.;
a='01 nov 2016'd;
b='18 nov 2016'd;
Sundays = intck('weekday234567w',a,b);
put _all_;
run;

Finding the day of the thirteenth of every month over a period of years

I am currently trying to solve some problems from the USACO training website in preparation for an unrelated C++ programming competition.
However, I am stuck on this problem:
Does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13th of each month lands on Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday over a given period of N years. The time period to test will be from January 1, 1900 to December 31, 1900+N-1 for a given number of years, N. N is non-negative and will not exceed 400.
The number N is provided in an input file and the output is to be a file with seven numbers in it, each representing the number of 13th's falling on a particular day of the week.
I was wondering how you guys would approach this problem. I am not looking for code or anything since that would just defeat the purpose of me doing this, instead just a starting point or an algorithm would be helpful.
So far the only thing I could think of is using the Doomsday Algorithm, however I am unsure about how I would implement that in code.
Any help would be greatly appreciated.
As Denny says, N is so small that you can easily iterate through the months using a table of days-in-a-month and a simple is-a-leap-year predicate to handle February. Just find out what day the 13th of Jan was in 1900 and then add up the elapsed days until 13th Feb, then 13th March etc.. Use a % operator to wrap the # of elapsed days back into a day-of-week value.
N is less than 400? well you just need to go over 365.25*400=146100 days at max. sounds easy to enumerate all of them, convert dates into year/month/date (with your favorite date conversion routine), testing for day of week is trivial.
I would precalculate the table though.
Just use brute force. Like this pseudocode example:
from datetime import date
day_names = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
'Saturday', 'Sunday']
counts = [0] * 7
for year in range(1900, 2300):
for month in range(1, 13):
counts[date(year, month, 13).weekday()] += 1
for day, count in zip(day_names, counts):
print('%s: %d' % (day, count))
The "hard" part is calculating the day of the week a date falls on. In C(++), you can use the mktime and localtime library functions if you know that your platform handles a large enough date range.

How do I set the date to the next weekday of my choice using c++?

I would like to determine the next date that has a day of the week value equal to something I specify.
For example, today is 6/21/2010 and the day of week value is 1 b/c today is a Monday. How do I find the next date with let's say a day of week value of 3.
I would like to consider all cases that come close to the end of something including month and year.
Is there any easy way to do this or do I have to manually check to see if it's close to the end of the month or year and make adjustments accordingly? I feel there is an easily and better solution than doing that.
You can stuff your values into a struct tm, and then normalize them with a call to mktime. This will ignore the day of week and day of year on input, and normalize the other values. For example, you can feed it an input of February 31st, and it'll convert that to March 3rd (or March 2nd for a leap year).
To use this, the normal sequence would be to call time to get the current time as a time_t. Then convert that to a struct tm with a call to localtime. Adjust the time in the struct tm as needed (e.g., if it says today is Tuesday, and you want Friday, add three to the day of the month). Then call mktime to normalize the values, in case you've (for example) overflowed from one week/month/year to the next.