How to calculate and compare DateTime with Integer(c#)

Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Feb 2008
Posts: 17
Reputation: hwa is an unknown quantity at this point 
Solved Threads: 0
hwa hwa is offline Offline
Newbie Poster

How to calculate and compare DateTime with Integer(c#)

 
0
  #1
Feb 29th, 2008
Example:

I have a table name A and have three column name OVER_DUE_DATE_TIME(date/time), DUE_DATE_TIME(date/time) and DURATION(Integer, in hours).

I need to do this validation: DUE_DATE_TIME + DURATION <= OVER_DUE_DATE_TIME

If the validation is wrong then should prompt the user error message.

May I have this solution in C# !!


Thanks in advance !!
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: How to calculate and compare DateTime with Integer(c#)

 
0
  #2
Feb 29th, 2008
you can do this with retrieving the information from the SQL server:

DATEADD(dd, DURATION, DUE_DATE_TIME)

Taking into account that DURATION is the integer in the amount of days (7 for a week, 14 for two weeks, etc.)

Otherwise make sure that your DUE_DATE_TIME is a valid date, then set it to a variable and add the duration to it:

date DDT = DUE_DATE_TIME;
DDT = DDT.AddDays(parseInt(DURATION));

if (DDT > OVER_DUE_DATE_TIME)
{
response.write("book is overdue");
}

Again, taking into account that duration is an integer in the amount of days.
Last edited by SheSaidImaPregy; Feb 29th, 2008 at 12:23 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 17
Reputation: hwa is an unknown quantity at this point 
Solved Threads: 0
hwa hwa is offline Offline
Newbie Poster

Re: How to calculate and compare DateTime with Integer(c#)

 
0
  #3
Mar 1st, 2008
Originally Posted by SheSaidImaPregy View Post
you can do this with retrieving the information from the SQL server:

DATEADD(dd, DURATION, DUE_DATE_TIME)

Taking into account that DURATION is the integer in the amount of days (7 for a week, 14 for two weeks, etc.)

Otherwise make sure that your DUE_DATE_TIME is a valid date, then set it to a variable and add the duration to it:

date DDT = DUE_DATE_TIME;
DDT = DDT.AddDays(parseInt(DURATION));

if (DDT > OVER_DUE_DATE_TIME)
{
response.write("book is overdue");
}

Again, taking into account that duration is an integer in the amount of days.

I want the Duration in Hours.

If the DUE_DATE_TIME(the time) + the DURATION is next day then the DUE_DATE_TIME should be increase one day and then compare to the OVER_DUE_DATE_TIME.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC