Solved

Customised Calendar

Posted on 2007-03-23
2
173 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now