me1258 Posted March 27, 2005 Posted March 27, 2005 I am trying to write a program that will take a start time and an end time and then tell me how many minutes of that time span fall with in a predetermined time frame. Example I log in at 13:00 I log out at 00:00 I want to know how much time (in minutes) elapsed in the range of 15:00 to 23:00 during that log in period The answer here would be 8 hrs or x minutes. Thanks Quote
Administrators PlausiblyDamp Posted March 27, 2005 Administrators Posted March 27, 2005 You could store the time when they login in one variable and then on exit calculate the difference i.e. Dim d1 As DateTime = DateTime.Now 'do something in between Dim d2 As DateTime = DateTime.Now Dim ts As TimeSpan = d2.Subtract(d1) MessageBox.Show(ts.Hours.ToString & ":" & ts.Minutes.ToString) 'or MessageBox.Show(ts.TotalMinutes.ToString) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
thenerd Posted March 27, 2005 Posted March 27, 2005 Yeah, but he needs to know how many of those minutes were in yet ANOTHER timespan. Quote
Administrators PlausiblyDamp Posted March 28, 2005 Administrators Posted March 28, 2005 My bad, he would just need to create a couple of date objects set to pre-determined timse and use those for comparison / subtraction. Dim d2 As DateTime = new DateTime(datetime.Today.Year,datetime.Today.Month, datetime.Today.Day, 15,0,0) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
tinJeff Posted May 23, 2006 Posted May 23, 2006 hi! i would like to know how to calculate a range of time in crystal report. When timein is 9:00am and out at 12:00pm. If the normal time of shift starts at 8:00am, how will i calculate undertime? Any help would be greatly appreciated. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.