Click here to Skip to main content
15,921,530 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,
I have to create job details when started or ended.

For this I create txtdated for date, drop down for Hour and minute.

Now I want to integrate date hour and minute as date and time.

Then Save it into Database. But I am not able to do this.

Please help.

Thanks
Posted
Comments
#realJSOP 4-Oct-10 7:54am    
What have you tried?

Why not use a DateTimePicker and store it as DateTime? That is what they are there for, after all...
 
Share this answer
 
Example:

string nowDate = "1/1/2010";
string hourMinites = "01:24";
string[] date = nowDate.Split('/');
string[] time = hourMinites.Split(':');
DateTime dt = new DateTime(Convert.ToInt32(date[2]), Convert.ToInt32(date[1]), Convert.ToInt32(date[0]), Convert.ToInt32(time[0]), Convert.ToInt32(time[1]), 0);
 
Share this answer
 
Comments
OriginalGriff 4-Oct-10 11:25am    
That is horrible!
What happens if they enter "1/Jan/2010"?
Or "March 2010"?
Or just 1/1/10?
Or use the Japanese date format "2010/1/27"?
or the American "3/27/2010"?
At least suggest DateTime.TryParse
C#
DateTime dt = date.AddHours(hours).AddMinutes(minutes);
 
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