codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Difference between two dates including From & To date  praveenhathwar at 10:23 on Tuesday, March 02, 2010
 

Hi All,

I am very much new to ASP programming. I am developing a Leave Management portal. I need to calculate the difference between two dates (including the From and To date).

For Example consider the below scenario:
A person applies leave from 01/03/2010 to 05/03/2010 and clicks on submit button.
In addition to checking all the mandatory fields, I have to check whether the number of days applied is greater than 3 (including from date and To date). If yes, I have to display an error message.

Please Help me out to solve this.

  Re: Difference between two dates including From & To date  L-GT at 21:56 on Wednesday, March 03, 2010
 

Hi,

To calculate the difference in date in days, you can use the following method:


DateTime leave;
DateTime back;
leave = Convert.ToDateTime(txtdate1.Text);
back = Convert.ToDateTime(txtdate2.Text);

TimeSpan gone = leave - back;
int daysgone = gone.Days

if(daysgone > 3)
{
//insert conditional code
}

As for the txtdate1.text, thats just however the user is passing their date value into your program. Hope this helps.



<Added>

Edit - O wow, sorry, didnt' notice you wanted this is javascript. Sorry.

<Added>

javascript:

var date1 = (input date)
var date2 = (input date)

var one_day = 1000*60*60*24;

Document.write(Math.ceil(date2.getTime() - date1.getTime())/(one_day))

source: http://www.javascriptkit.com/javatutors/datedifference.shtml

  Re: Difference between two dates including From & To date  brian500 at 02:58 on Friday, March 12, 2010
 



Tutorials PHP Tutorials
Calculating Difference Between Two Dates Using PHP
By Amrit Hallan
2005-10-18

Calculating difference between two dates using PHP
AdsSpy: 15 sites philadelphia mortgage loans by this AdSense ID Suppose you want to know the age of a person given her birth date. Let’s say her birth date is "09-23-1969". Although in this case you might las vegas investment property say that we don’t need a program to compute the age, but assuming there are 1000s of records in your database and for every person you have to print a report like:Sheila is 29 years oldFatima is 33 years oldPeter is 17 years old
… and so onIn the database we don’t generally store what the person’s age is — we store what the person’s date of birth is. This is because given the date of birth, we can always deduct it from today’s washington mortgage loans date and calculate the number of years that person has lived so far. Calculating date difference also comes handy if you are running a subscription-based website. You need to know for how many days a person has been using your website and when the subscription is due. So in this tip we learn to write a function that columbus mortgage loans returns us the number of days elapsed between two dates. First the function (I’ll discuss it later on)

function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;
}

Now let us see how we use this function:

$date1="07/11/2003";
$date2="09/04/2004";

print "If we minus " . $date1 . " from " . $date2 . " we get " . dateDiff("/index.html", $date2, $date1) . ".";

which generates If we minus 07/11/2003 from 09/04/2004 we get 421.

The dateDiff() functions uses two PHP functions viz., explode() and gregoriantojd(). The explode() function is used mostly to convert strings san francisco real estate into arrays. It takes two arguments: the separator and the string. So if

$string="Trees, plants, bushes";
$stringparts=explode(", ", $string);

then $stringparts[0] holds "Trees", $stringparts[1] holds "plants" and $stringparts[2] holds "bushes". The separator is ", ". Similarly, in the above example, $date_parts1[0] holds the month part, $date_parts1[1] holds the day part and $date_parts1[2] holds the year part and these are the arguments that the function gregoriantojd() needs. The syntax of the gregoriantojd() function is

gregoriantojd($month, $day, $year)

But why do we need this function? Without going into the gory details, it changes the date into a big number from which another number (obtained from another date) can be deducted. Having said that, let us now see a few applications for this function: first the age thing. The following snippet of code gives us the age of a person according to the current date.

  Re: Difference between two dates including From & To date  amery buck at 06:23 on Tuesday, March 30, 2010
 

Beautiful blog with great informational content. Mostly certifications related and including From & To date related topics are really very good. <a href="http://www.sure-braindumps.com/70-290.htm">70-290 braindump</a>, <a href="http://www.sure-braindumps.com/70-290.htm">70-290 latest dumps</a> and <a href="http://www.sure-braindumps.com/70-562.htm">braindumps 70-562</a> are also good topics. Thanks for this great sharing.

  Re: Difference between two dates including From & To date  amery buck at 13:39 on Monday, April 12, 2010
 

Hi all,

I am Hank Freid and I like your

blog very much.

  Re: Difference between two dates including From & To date  clark40 at 05:44 on Monday, June 21, 2010
 

Codes can be used for brevity. When telegraph messages were the state of the art in testking ccna dumps rapid long distance communication, elaborate systems of commercial codes that encoded complete phrases into single words (commonly five-letter groups) were developed, so that telegraphers became conversant with such "words" as BYOXO ("Are you trying to weasel out of our deal?"), LIOUY ("Why do you not answer my question?"), BMULD ("You're a skunk!"), or AYYLU ("Not clearly coded, repeat more clearly."). Code words were chosen testking ccsa for various reasons: length, pronounceability, etc. Meanings were chosen to fit perceived needs: commercial negotiations, military terms for military codes, diplomatic terms for diplomatic codes, any and all of the preceding for espionage codes. Codebooks and codebook publishers proliferated, including one ccnp run as a front for the American Black Chamber run by Herbert Yardley between the First and Second World Wars. The purpose of most of these codes was to save on cable costs. The use of data coding for data compression predates the computer era; an early example is the telegraph Morse code where more-frequently used characters have shorter representations. Techniques such as Huffman coding are now used by computer-based algorithms to ccvp compress large data files into a more compact form for storage or transmission

  Re: Difference between two dates including From & To date  helenk579 at 02:09 on Sunday, June 27, 2010
 



Thanks you for the post.


_________________
Watch The Twilight Saga Eclipse Online Free


  Re: Difference between two dates including From & To date  jimgreen at 00:49 on Monday, July 12, 2010
 

I learn a lot from this post, thank you!


_________________
Watch Grown Ups Online free

  Re: Difference between two  stevemartyn at 05:41 on Friday, October 15, 2010
 

at the moment I'm working 70-445
on writing a code for a interactive project. This project is made out of a 3dmodel, that I made in 3dsmax. I want to animate this model, and make it respond to an actual person 70-443
by motion detectors and a camera that works together with a javascript code.I'm trying to make this animated model walk to different coordinates. When doing so I have two different choices, either my object 'slides' to a location, or the object do 70-444
es a 'walkcycle' which remains in place. (So the background moves.) What I want, ideally, is a sliding walkcycle. This has to have a place where it has to stop, so it doesn't move out of the picture. (I hope this still makes some sense!)70-442


  Re: Difference between two dates including From & To date  KarenG at 06:18 on Saturday, October 16, 2010
 

Very interesting discussion. I am glad to have found this and I am now kotting notes. Thanks.
-------------------
KarenG of chicago website design company

  Re: Difference between two dates including From & To date  Elain at 02:50 on Friday, October 22, 2010
 

I think the answer is very clear and helpful! Thanks for your wonderful knowledge with us!



---------------------------------
http://www.logo-maker.net



<Added>

I think the answer is very clear and helpful! Thanks for your wonderful knowledge with us!

---------------------------------
http://www.logo-maker.net








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Regular Savings Accounts
•  Re: ASP and Ms-access
•  Re: CSS 3.0 animation features
•  Re: Dhtml menu, submenu losing focus. I`m so close!
•  Re: ASP Cookies
•  Re: Difference between two dates including From & To date
•  Re: Need Javascript Multiple sidebar menu with sliding effects
•  Re: lightweight and heavyweight component
•  Re: Insert Contents of .txt file into a .html page


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010