datepart in asp.net c#

Posted by Jahi under ASP.NET on 3/3/2011 | Points: 10 | Views : 7301 | Status : [Member] | Replies : 5
hw can i take date from a datetime ?


example: i want to take date(25) from 25/12/2005




Responses

Posted by: Prabhakar on: 3/3/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Jahi


which control u fetch date . . as a datepicker or else .

basically in asp.net u want this format easily


DateTime dt;
dt = DateTime.Today.Date;

Best Regard's
Prabhakar

Jahi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 3/3/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Try this...

string sDate = "12/25/2008";  // Date in MM/dd/yyyy Format

//Get Date
string sDay = DateTime.Parse(sDate).Day.ToString();
//Get Month
string sMonth = DateTime.Parse(sDate).Month.ToString();
//Get Year
string sYear = DateTime.Parse(sDate).Year.ToString();


Cheers :)



Thanks,
T.Saravanan

Jahi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jahi on: 3/3/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Saravanan sir,


Thanks a lot for your comments. Now , my problem solved.

Thanks .

Regards
Jaheena


Jahi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 3/3/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
nice code Saravanan :) seems anyone can get anything they want from date..

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

Jahi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 3/3/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Thanks Jahi & Naimish......

Thanks,
T.Saravanan

Jahi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response