Click here to Skip to main content
11,718,589 members (88,606 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 ASP.NET
Hi All,

I am using a drop down list for selecting the month in .aspx page.
I have to get last date of the selected month in .aspx.cs page.
(some months have 30 days and some have 31 days)

How can I do this?


Regards,

N.SRIRAM
Posted 19-Jan-11 20:53pm
SRIRAM 21.5K
Edited 19-Jan-11 21:42pm
Dalek Dave433.2K
v2
Comments
Dalek Dave at 20-Jan-11 3:42am
   
Edited for Readability.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,

User
DateTime.DaysInMonth(int year,int month)  

Pass year and month you select. function return total days in month.

umesh
  Permalink  
Comments
Rajesh Puli at 20-Jan-11 3:00am
   
Good answer
soni uma at 20-Jan-11 3:00am
   
thnx
JF2015 at 20-Jan-11 3:00am
   
Good answer
Pravin Patil, Mumbai at 20-Jan-11 3:33am
   
100% Correct
Dalek Dave at 20-Jan-11 3:42am
   
Couldn't put it better myself.
Agent_Spock at 9-Mar-14 7:18am
   
+5 vote, according to me sir, no other solution can be better answer than this.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
DateTime origDT = Convert.ToDateTime("02/10/2011");
DateTime lastDate = new DateTime(origDT.Year, origDT.Month, 1).AddMonths(1).AddDays(-1);
Hope this may help you.
  Permalink  
v3
Comments
JF2015 at 20-Jan-11 3:59am
   
Very good alternative to the previous post. 5+
Blesson Mathew at 20-Jan-11 4:05am
   
Thank you JF2015
Member 8233601 at 18-Jun-13 3:23am
   
5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

See Here[^]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 651
1 OriginalGriff 210
2 F-ES Sitecore 185
3 Jochen Arndt 160
4 Maciej Los 130
0 OriginalGriff 535
1 Maciej Los 529
2 Richard MacCutchan 440
3 CHill60 415
4 F-ES Sitecore 415


Advertise | Privacy | Mobile
Web04 | 2.8.150901.1 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100