473,779 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4231
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**@discussio ns.microsoft.co mwrote in message
news:A2******** *************** ***********@mic rosoft.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(dtmTod ay.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 GetFirstDayInMo nth(DateTime dt)
{
DateTime dtRet = new DateTime(dt.Yea r, 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**@discussio ns.microsoft.co mwrote in message news:A2******** *************** ***********@mic rosoft.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**@discussio ns.microsoft.co mwrote in message
news:A2******** *************** ***********@mic rosoft.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(dtmTod ay.Year, dtmToday.Month, 1);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 1 '07 #6
"Paul" <Pa**@discussio ns.microsoft.co mwrote in message
news:7F******** *************** ***********@mic rosoft.com...
Thanks for the replies, it works!
DateTime dtmToday = DateTime.Now;
DateTime dtmFirstOfMonth = new DateTime(dtmTod ay.Year, dtmToday.Month, 1);
DateTime dtmFirstThursda y = dtmFirstOfMonth ;
while (dtmFirstThursd ay.DayOfWeek != DayOfWeek.Thurs day)
{
dtmFirstThursda y = dtmFirstThursda y.AddDays(1);
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 1 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5740
by: chennakeshava_ramesh | last post by:
hi, I have a problem, I am not able to find out which day of the week it is using the calendar class. I am using set() function to set the date and want to find out which day i.e mon,tue etc of the week it is . Can anyone help me out with this, regards
3
9629
by: johkar | last post by:
I need to document.write out a select list populated with the dates for the first and third Wednesday of each month. How do I get to the actual days? <select name="mySelect"> <option value="Oct 1, 2003">Oct 1, 2003</option> <option value="Oct 15, 2003">Oct 15, 2003</option> .....and so on for a continual 12 month period </select> Thanks,
3
2958
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms application that is going to be used to extract data from a legacy system (VSAM based mainframe file structure), and output data in pipe-delimited record layouts, multiple record types per file, one file per chosen client. I have been working on...
23
14062
by: thebjorn | last post by:
For the purpose of finding someone's age I was looking for a way to find how the difference in years between two dates, so I could do something like: age = (date.today() - born).year but that didn't work (the timedelta class doesn't have a year accessor). I looked in the docs and the cookbook, but I couldn't find anything, so
3
4110
by: Sebastian | last post by:
Hello all I have a report where I have two nested groups. I know there are only three standard options for running sum: None, Over Group and Over All. I have a MyTextBox in detail section where the data is summed over group. But the data is summed over the second group. When a new group begins MyTextBox value is resetting to zero. I need a running sum over the first group so when another second group begins MyTextBox value will
10
8364
by: meltedown | last post by:
If I have an sql date, such as "2006-11-19" is there a way using either sql or php date and time functions to get the date of the the first day of the month ?
44
10236
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
4
39345
by: perryclisbee via AccessMonster.com | last post by:
I have dates of service for several people that range all over each month. ie: patient had dates of service of: 7/3/2006, 7/24/2006 and 7/25/2006. I need to create a new field via a query that will convert each of the records of these service dates to the first date of that month, with results showing: 7/1/2006, 7/1/2006, 7/1/2006. How would you place an expression on a query that will convert any given date to the first day of the month...
4
5178
by: jriechers | last post by:
I need to create a database that will be used to schedule patches. Many of our patches happen on the 1st Saturday of the month, but some happen on the 2nd Thursday after the 1st Tuesday every month. Ive been attempting to use the DATEPART and WEEKDAY functions but without success. Figuring out the 1st Saturday shouldnt be to hard, even if I havent managed to figure that out just yet, but the other is beyond my experience.
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.