how can i get current time when i select date from calendar control in asp.net [Resolved]

Posted by Lakn2 under ASP.NET on 5/17/2011 | Points: 10 | Views : 5467 | Status : [Member] | Replies : 3
Hi,

I have one column like patientjoineddate in sql server in that one i want to insert present date and current time when i select date from calendar control.
But problem is it is showing default time as 12:00AM .How can i change it.

Thanks&Regards
LakshmiNarayana Nalluri.



Responses

Posted by: Lakn2 on: 5/17/2011 [Member] Starter | Points: 25

Up
0
Down

Resolved
thank you it's working fine

Thanks&Regards
LakshmiNarayana Nalluri.

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

Posted by: Ndebata on: 5/17/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
1. First thing if you want to store current datetime for an particular event in database , try to use GetDate() in SQL server.
2. What if you have selected some other date in calendar control, thats why its time is defaulted.
3. Still if you want your functionality :) use the following code to create a datetime that will give you desired result.

DateTime selected=Calendar1.SelectedDate;
DateTime dt = new DateTime(selected.Year, selected.Month, selected.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);


Thanks,
Debata



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

Posted by: Xiaoyuandlg on: 5/15/2014 [Member] Starter | Points: 25

Up
0
Down
Ndebata's code also helped me on this question. Much more practical than the calendar C# tutorial I find:

http://www.kettic.com/winforms_ui/csharp_guide/calendar_get_started.shtml

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

Login to post response