Click here to Skip to main content
16,013,465 members
Home / Discussions / C#
   

C#

 
AnswerRe: Read/Write issues asap. Pin
Guffa17-May-06 8:18
Guffa17-May-06 8:18 
GeneralRe: Read/Write issues asap. Pin
DeepToot18-May-06 2:44
DeepToot18-May-06 2:44 
GeneralRe: Read/Write issues asap. Pin
Guffa18-May-06 7:44
Guffa18-May-06 7:44 
GeneralRe: Read/Write issues asap. Pin
DeepToot18-May-06 7:47
DeepToot18-May-06 7:47 
QuestionExcel.XlDirection problem Pin
StyleGuide17-May-06 5:56
StyleGuide17-May-06 5:56 
QuestionDate And Time Pin
| Muhammad Waqas Butt |17-May-06 5:55
professional| Muhammad Waqas Butt |17-May-06 5:55 
AnswerRe: Date And Time Pin
NaNg1524117-May-06 6:54
NaNg1524117-May-06 6:54 
AnswerRe: Date And Time Pin
NaNg1524118-May-06 2:37
NaNg1524118-May-06 2:37 
for your request (I got the email... but there is no msg here, so if I would post there you wouldn't get the email notification).

I've built this method, a small method that all you need is two datetimes...

private TimeSpan SubTime(DateTime dt1, DateTime dt2)
{
    // Substracts dt1 from dt2
    TimeSpan ts = TimeSpan.Parse(dt2.ToString("H:mm:ss"));
    return ts.Subtract(TimeSpan.Parse(dt1.ToString("H:mm:ss")));
}


now you use it like this:

DateTime dateDiff = DateTime.Parse(SubTime(DateTime.Now, DateTime.Now.AddHours(3)));

simple no?

btw I think DateDiff is in SQL... this is C#.

if you want to pick datetime you can use the datetimepicker that has alot of functionality, and very comfort, if you want to display the DateTime you just do in a label, Text property = DateTime1.ToString("formatting")
eg. DateTime1.ToString("dd-month-yyyy hh:mm AM/PM") // just built it for you from a book I have - needed to custom make some stuff.... should work and if theres a problem try to search it, or if theres a real problem send me a msg...

Hope I helped Big Grin | :-D
NaNg.
QuestionDataGridView - row height bigger than grid's height Pin
Pedro Miguel Pereira17-May-06 5:08
Pedro Miguel Pereira17-May-06 5:08 
Question2.0 gridview Pin
fmardani17-May-06 4:48
fmardani17-May-06 4:48 
QuestionPassing enum as a parameter Pin
dayakar_dn17-May-06 4:43
dayakar_dn17-May-06 4:43 
AnswerRe: Passing enum as a parameter Pin
NaNg1524117-May-06 5:07
NaNg1524117-May-06 5:07 
QuestionToolStripComboBox problem Pin
Wjousts17-May-06 3:47
Wjousts17-May-06 3:47 
QuestionCheckbox control Pin
jackalfb17-May-06 3:31
jackalfb17-May-06 3:31 
AnswerRe: Checkbox control Pin
stancrm17-May-06 3:45
stancrm17-May-06 3:45 
GeneralRe: Checkbox control Pin
jackalfb17-May-06 4:38
jackalfb17-May-06 4:38 
GeneralRe: Checkbox control Pin
microsoc17-May-06 20:04
microsoc17-May-06 20:04 
GeneralRe: Checkbox control Pin
jackalfb20-May-06 1:36
jackalfb20-May-06 1:36 
AnswerRe: Checkbox control Pin
Wjousts17-May-06 3:49
Wjousts17-May-06 3:49 
AnswerRe: Checkbox control Pin
jackalfb17-May-06 4:33
jackalfb17-May-06 4:33 
QuestionLooping through form elements Pin
Brendan Vogt17-May-06 3:23
Brendan Vogt17-May-06 3:23 
AnswerRe: Looping through form elements Pin
stancrm17-May-06 3:34
stancrm17-May-06 3:34 
AnswerRe: Looping through form elements Pin
Wjousts17-May-06 3:53
Wjousts17-May-06 3:53 
GeneralRe: Looping through form elements: THANKS Pin
Brendan Vogt17-May-06 4:22
Brendan Vogt17-May-06 4:22 
GeneralRe: Looping through form elements: THANKS Pin
Wjousts17-May-06 4:33
Wjousts17-May-06 4:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.