| | |
How to calculate and compare DateTime with Integer(c#)
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2008
Posts: 17
Reputation:
Solved Threads: 0
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 !!
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 !!
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
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.
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.
•
•
Join Date: Feb 2008
Posts: 17
Reputation:
Solved Threads: 0
•
•
•
•
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.
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: login validation
- Next Thread: drop down list selected index change doesn't work in mozilla
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor appliances application asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions dataaccesslayer database datagridview datagridviewcheckbox datalist development dgv dialog dropdownlist dynamically edit expose feedback fileuploader fill flash form formatdecimal formview google gridview gudi iframe iis image javascript list listbox login microsoft mono mouse mssql multistepregistration news numerical opera panelmasterpagebuttoncontrols parent project radio redirect registration relationaldatabases reportemail richtextbox save schoolproject search security select sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking treeview unauthorized validatedate validation vb.net video videos view vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers






