Click here to Skip to main content
15,909,437 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 Column in database with 30 dates
my 1st date start with 01/04/2013 and 2nd ends with 30/04/2014
and on web page it will show in a string format
i'm using linq to for showing date on my web page.

Now how can check whether the particular date is Sunday.

below is my linq query
C#
lstAbsentReconciled = (from db_Date in Date.AsEnumerable()
                      join db_Student in Student
                      on db_Date.roll_no equals db_Student.roll_no
                      where db_Date.roll_no == lngRollNo
                      && (db_Date.student_dt >= EndDt && db_Date.student_dt <= StartDt)
                      select new Student {
                         Student_id = db_Date .Student_id,
                         student_dt = ConvertToUserDate(db_Date.student_dt),
                         roll_no = db_Date.roll_no,
                      }).Distinct().ToList();

This Code is giving me my result...but how'll come to know that particular date from between 2 dates is sunday...!!
Posted
Updated 22-Apr-14 21:38pm
v3

there's plenty of code 'out there in the wild' to tell what day of the week a particular date is - here is but one hit from a search http://msdn.microsoft.com/en-us/library/bb762911(v=vs.110).aspx[^]

Does that solve the issue ? Im guessing you can also cast/get the same information from the database server, depending on what db server type animal you are using - Oracle for example has a large number of date functions

'g'
 
Share this answer
 
C#
student_dt.DayOfWeek = DayOfWeek.Sunday


[^]
 
Share this answer
 
v2
For everything concerning DateTime handling in .NET, you should first refer to the MSDN page of DateTime type; there you will find every property/method this type exposes.
DateTime Structure[^]
 
Share this answer
 

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