Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ammend DateTime Properties

Status
Not open for further replies.

Naoise

Programmer
Dec 23, 2004
318
IE
I have a datetime value and I want to ammend its time and minutes properties based on selected drop down values. These are read only properties however. How can I achieve this? Any help appreciated.
 
Well it's more like I have a drop down of hours so 0 to 23 and a drop down of minutes 0 to 59 and I want to set it to a specific value. Any easy way to do this?

If I go d.AddHours(MySelectedValue - d.Hour) will this just change the hour value or will it affect the overall date? As in if it is close to midnight would there ever be a possibility that it could change the date on me? I just want something that will set the hour and date in isolation for a given datetime.
 
Why don't you use a date/time picker control?

It returns a DateTime value.
 
so you have a date and you want to add a time to it.

how about creating a new one?

OTTOMH:

Code:
DateTime supplied = someArbitraryValue;
int hours = hoursEntered;
int minutes = minutesEntered;

DateTime newWithTime = new DateTime(supplied.Year, supplied.Month, supplied.Day, hours, minutes, 0);


mr s. <;)

 
True :) - My obsession with ammending the existing one blurred my vision on this one. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top