Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

find the first thursday from a given month

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul - 01 Aug 2007 00:46 GMT
HI I have a stored procedure that returns data with a date field in the form
of a DateTime type.  I need to place data in variables based on days of the
week starting with the first thursday of the month.  So the week would be
week 1= (first thursday of the month through the next wed).  So for example
for July 07 the first thursday is july5th so the first week would be thursday
july 5th , friday july 6th, sat july 7th, sun july 8th, mon july 9th, tue
july 10th and wed july 11th.  The second week would start with thursday july
12.  I think I can do this if I can just get the first thursday of the month
of the date that is read in but not quite sure how to do this?  I am also
passing in the day of the week string (mon, tue) ect from the same stored
procedure.
Thanks Paul.
Signature

Paul G
Software engineer.

Hans Kesting - 01 Aug 2007 08:41 GMT
> HI I have a stored procedure that returns data with a date field in
> the form
[quoted text clipped - 18 lines]
> procedure.
> Thanks Paul.

Find out what day the first of that month is, then you know how many
days to add to get to the first thursday.

Hans Kesting
Paul - 01 Aug 2007 15:48 GMT
Hi thanks for the response.  Yes I think what I need is the integer value of
the first thursday of the month.  I currently have read in the date as a
datetime type.  Just wondering how to get the first day of the month?
Signature

Paul G
Software engineer.

> > HI I have a stored procedure that returns data with a date field in
> > the form
[quoted text clipped - 23 lines]
>
> Hans Kesting
Juan T. Llibre - 01 Aug 2007 16:15 GMT
re:
!> Just wondering how to get the first day of the month?

public static DateTime GetFirstDayInMonth(DateTime dt)
{
DateTime dtRet = new DateTime(dt.Year, dt.Month, 1, 0,0,0); return dtRet;
}

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
> Hi thanks for the response.  Yes I think what I need is the integer value of
> the first thursday of the month.  I currently have read in the date as a
[quoted text clipped - 27 lines]
>>
>> Hans Kesting
Mark Rae [MVP] - 01 Aug 2007 16:16 GMT
> Hi thanks for the response.  Yes I think what I need is the integer value
> of
> the first thursday of the month.  I currently have read in the date as a
> datetime type.  Just wondering how to get the first day of the month?

DateTime dtmToday = DateTime.Now;
DateTime dtmFirstOfMonth = new DateTime(dtmToday.Year, dtmToday.Month, 1);

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Paul - 01 Aug 2007 18:36 GMT
Thanks for the replies, it works!
Signature

Paul G
Software engineer.

> > Hi thanks for the response.  Yes I think what I need is the integer value
> > of
[quoted text clipped - 3 lines]
> DateTime dtmToday = DateTime.Now;
> DateTime dtmFirstOfMonth = new DateTime(dtmToday.Year, dtmToday.Month, 1);
Mark Rae [MVP] - 01 Aug 2007 18:50 GMT
> Thanks for the replies, it works!

DateTime dtmToday = DateTime.Now;
DateTime dtmFirstOfMonth = new DateTime(dtmToday.Year, dtmToday.Month, 1);
DateTime dtmFirstThursday = dtmFirstOfMonth;
while (dtmFirstThursday.DayOfWeek != DayOfWeek.Thursday)
{
   dtmFirstThursday = dtmFirstThursday.AddDays(1);
}

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.