0

here is the code:

Resource_Time_Spent resTimeSpent = new Resource_Time_Spent();
Resource_TimeSpan resTimeSpan = new Resource_TimeSpan();
resTimeSpan.ReplyId = ticketReply.ID;
resTimeSpan.StaffId = ddl.SelectedValue;
resTimeSpan.TicketId = ticketid;
string[] span = tbtxttimespent.Text.Split(':');
string HH = string.Empty;
string MM = string.Empty;
if (span[0].Length <= 1) {
    HH = "0" + span[0];
}
else { HH = span[0]; }
if (span[1].Length <= 1) {
    MM = "0" + span[1];
}
else { MM = span[1]; }
resTimeSpan.TimeSpent = HH + ":" + MM + ":" + "00";
resTimeSpan.TimeSpent = this.getTimeSpent(span[0], span[1]).ToString();//sumanth removed commnts
if (!string.IsNullOrEmpty(tbtxtfromdate.Text)) {
    resTimeSpan.FromDt = Convert.ToDateTime(tbtxtfromdate.Text);
}
if (!string.IsNullOrEmpty(tbtxttodate.Text)) {
    resTimeSpan.ToDt = Convert.ToDateTime(tbtxttodate.Text);
}
resTimeSpan.FromTimeSpent = this.getTimeSpent(tbtxtfromdateHours.Text, tbtxtfromdateMinutes.Text).ToString();
resTimeSpan.ToTimeSpent = this.getTimeSpent(tbtxttodateHours.Text, tbtxttodateMinutes.Text).ToString();
if (chkbox.Checked) {
    resTimeSpan.isBusinessHr = true;
}
resTimeSpent.Submit(resTimeSpan);

}

exception: if return time is morethan 24 hours it is giving range exception

Abhitalks
  • 27,721
  • 5
  • 58
  • 81
  • TimeSpans representing more than 24 hours are perfectly valid. Where is the exception occurring? (Always good information to include). – James Dec 01 '14 at 05:57
  • in sql server the datatype i used is timestamp and when i insert data morethan 24 hours then it is giving the above mentioned exception.thankyou – sumanth rao Dec 01 '14 at 06:09
  • Sql server? You've left out any kind of Sql code or any indication that this is sql data. Where are you doing a SQL insert? Also, there is no 'timestamp' data type in SQL that is accessible by users. Are you talking about a 'time' type? Yes, those are limited to 24 hours because they are intended to represent the time of day, not a time span. If you want a time span, you should just convert to seconds or minutes and store in a 'real' or 'float' column. – James Dec 01 '14 at 06:15
  • Thanks for the above but i need that code regarding the change of range (time) more than 24 hours. – sumanth rao Dec 01 '14 at 06:39
  • You CAN'T have a SQL time of more than 24 hours, and timestamp has nothing to do with dates or times. See http://stackoverflow.com/questions/8119386/how-to-convert-sql-servers-timestamp-column-to-datetime-format. If you are really looking for help, you will need to provide more information. We have no idea what a Resource_Time_Spent or a Resource_TimeSpan object is, because you haven't provided that code or any sort of information indicating what those are, or where you are getting an error and exactly what the error message is. – James Dec 01 '14 at 15:53
  • yes i am using time datatype in sqlserver, it is showing the following exception.. SqlDbType.Time overflow. Value '48.02:00:00' is out of range. Must be between 00:00:00.0000000 and 23:59:59.9999999. – sumanth rao Dec 02 '14 at 10:11
  • You have used a SQL data type that was designed only to represent the time of day. 48:02:00 is not a valid time of day. If you want a time span, you must change the column (and any corresponding client-side types) to the number of elapsed seconds, minutes, days, etc., with whatever resolution you desire (integer, single-precision floating point, double-precision floating point, decimal, etc.). – James Dec 03 '14 at 02:59

0 Answers0