469,927 Members | 1,978 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

find the first thursday from a given month

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.
--
Paul G
Software engineer.
Jul 31 '07 #1
6 3996
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.
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
Aug 1 '07 #2
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?
--
Paul G
Software engineer.
"Hans Kesting" wrote:
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.

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
Aug 1 '07 #3
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:A2**********************************@microsof t.com...
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);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 1 '07 #4
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/
======================================
"Paul" <Pa**@discussions.microsoft.comwrote in message news:A2**********************************@microsof t.com...
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?
--
Paul G
Software engineer.
"Hans Kesting" wrote:
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.

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


Aug 1 '07 #5
Thanks for the replies, it works!
--
Paul G
Software engineer.
"Mark Rae [MVP]" wrote:
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:A2**********************************@microsof t.com...
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);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 1 '07 #6
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:7F**********************************@microsof t.com...
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);
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 1 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by chennakeshava_ramesh | last post: by
3 posts views Thread by johkar | last post: by
3 posts views Thread by Professor Frink | last post: by
10 posts views Thread by meltedown | last post: by
4 posts views Thread by perryclisbee via AccessMonster.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.