Click here to Skip to main content
15,884,598 members
Please Sign up or sign in to vote.
1.12/5 (5 votes)
See more:
hi friends

I need to find the day of week using date time


example:

Date: 2013-06-24

it is 4th Monday ( i need to find this 4)
week number is 5

by using week number function i m getting 5,
but i need to find how can i get 4 as output
Posted
Updated 27-Mar-17 18:59pm
v2
Comments
Rajesh Anuhya 24-Jun-13 6:52am    
Have you tryed anything?
[no name] 24-Jun-13 6:52am    
Why are you reposting this when you have already answer it yourself? http://www.codeproject.com/Answers/610913/findplusdateplususingplusgivenplusyear-2cmonth-2cw#answer2
siva575 24-Jun-13 7:10am    
that one is different

when i now the week number and day i can find date

here i have to find exact week of the date

see the today date it's 5th week and monday right

but it is 4th monday in this month i need to find the 4
Nelek 24-Jun-13 7:42am    
If you know the number of the week, and you now in which day the month started... Monday < Saturday, so 5th week, 1st was saturday, then 4th monday.

Try this:
C#
public static void Main()
  {
    DateTime dt = new DateTime(2003, 5, 1);
    Console.WriteLine("Is Thursday the day of the week for {0:d}?: {1}",
                       dt, dt.DayOfWeek == DayOfWeek.Thursday);
    Console.WriteLine("The day of the week for {0:d} is {1}.", dt, dt.DayOfWeek);
  }

From: MSDN[^]
 
Share this answer
 
v2
Get the correct week number of a given date[^] Hope this will give you more info.
 
Share this answer
 
v2
Try this, hopefully this should solve your problem

C#
class Program
{
    static void Main(string[] args)
    {
        DateTime dt = new DateTime();
        dt = DateTime.Parse("24-Jun-2013");

        int d = ReturnDayCount(dt);
    }

    static int ReturnDayCount(DateTime inDate)
    {
        return (inDate.Day % 7) == 0 ? (inDate.Day / 7) : (inDate.Day / 7) + 1;
    }

}
 
Share this answer
 
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900