Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 subtracting values in a textbox

Author  Topic 

shemayb
Posting Yak Master

159 Posts

Posted - 2007-09-26 : 21:22:17
What is the process of subtracting values(Date Values) in a textbox?

Funnyfrog

shemayb
Posting Yak Master

159 Posts

Posted - 2007-09-26 : 21:42:09
Datediff function in c#.

Funnyfrog
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2007-09-26 : 21:48:46
Hey funnyfrog

am i missing something. I also have some questions I could answer myself....

Actually I know a joke like that -

"Why do firemen wear red braces to hold their trousers up?"

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-09-26 : 21:53:36
is there a datediff function in c#?

Funnyfrog
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2007-09-26 : 22:00:38
Ah - my apologies, I didn't understand what you were asking...

check these
[url]http://www.dotnetspider.com/kb/Article1552.aspx[/url]
[url]http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic11262.aspx[/url]
[url]http://www.aspcode.net/C-Datediff.aspx[/url]

let us know if that's not what you're after

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-09-26 : 22:05:20
it's ok...thank you..How about if i have time values in my textbox and i want that my endtime will be subtracted to my strttime and then divide it by 60?is there a way for me to do that in c#?

Funnyfrog
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2007-09-26 : 22:14:51
You mean something different to this
DateTime start = some value;
DateTime end = some other value;
TimeSpan diff = start - end;
hours = diff.TotalHours;
?

--
I'm not schooled in the science of human factors, but I suspect that surprise is not an element of a robust user interface.
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-09-26 : 22:23:20
if i divide it with 60 can i put it like that of the ff?

DateTime start = some value;
DateTime end = some other value;
TimeSpan diff = (start - end/60);(newly added)
hours = diff.TotalHours;

Funnyfrog
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2007-09-26 : 22:29:21
I don't think what you've added makes any sense. Why are you dividing by 60? diff.TotalHours is already in hours. What are you trying to calculate?

--
I'm not schooled in the science of human factors, but I suspect that surprise is not an element of a robust user interface.
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-09-26 : 22:31:10
i added that because that is the formula that i needed to calculate the total time.

Funnyfrog
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2007-09-26 : 22:36:21
Yep, but what I'm saying is that diff.totalHours is already the total time. You don't need to divide by 60. Normally you divide by 60 if you were given the answer as minutes.

So if you really want to divide something by sixty, you could change the code like this
            TimeSpan diff = start - end;
Double hours = diff.TotalMinutes/60;


Is that what you're after?

--
I'm not schooled in the science of human factors, but I suspect that surprise is not an element of a robust user interface.
Go to Top of Page
   

- Advertisement -