Solved

Customised Calendar

Posted on 2007-03-23
2
177 Views
Last Modified: 2010-04-14
Hi experts, I would like to build a simple calendar on a seven rows by five columns table. It is used to fill in scheduled items. It is something like the datetimepicker control. I would like to know how to determine the first date so that I can start to fill the "cell".
0
Comment
Question by:novknow
  • 2
2 Comments
 
LVL 9

Expert Comment

by:ripahoratiu
ID: 18778895
You mean the first moday date in or out the month of a given date? Let's say you start with a known date: myDateTime (could be DateTime.Now)

            DateTime FirstDateOfMonth = myDateTime.AddDays(1-myDateTime.Day);
// FirstDateOfMonth contains the first date in month. If  you want to find out what's the day of week of
// the first of the month just ask it with FirstDateOfMonth.DayOfWeek
// if you want to complete to the first monday regradless of the start day of the month contineu with:
            DateTime FirstSundayToDisplay = FirstDateOfMonth;
            if (FirstDateOfMonth.DayOfWeek != DayOfWeek.Monday)
            {
                FirstSundayToDisplay = FirstDateOfMonth.AddDays(-(long)(FirstDateOfMonth.DayOfWeek));
            }


That's all...

0
 
LVL 9

Accepted Solution

by:
ripahoratiu earned 500 total points
ID: 18778912
....replace all apearences of word monday with sunday. The first sunday. In Europe the week begins monday :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
RLDC Reporting in Visual studio 11 30
SQL Query Help Top 1 and Distinct? 6 36
Syntax Issue with SSIS module 26 105
IEnumerable<T> to a List<T> 8 40
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question