Jump to content


Photo

Subtração De Duas Datas


  • Faça o login para participar
9 replies to this topic

#1 wendel

wendel

    Turista

  • Usuários
  • 32 posts
  • Sexo:Não informado

Posted 05/02/2006, 00:43

Pessoal,

Preciso fazer a subtração de duas datas, ou seja dois campos, DATA1 E DATA2, mais ou menos assim...

eu digito a 'data1' = 01/01/2006
e digito a 'data2' = 01/01/2007

o que eu preciso é que me mostre quantos dias tem entre estas datas, ou seja...

DATA2 - DATA1 = 01/01/2007 - 01/01/2006

e apresenta em um campo abaixo...

NUMERO DE DIAS : 365

isso que preciso, se alguem puder me ajudar, desde já grato, um abraço.
WLSistemas para Web
atendimento@wlsistemas.com
Wendel Lopes - Diretor

#2 Thales Medeiros

Thales Medeiros

    24 Horas

  • Usuários
  • 426 posts
  • Sexo:Não informado
  • Localidade:Juiz de Fora/MG
  • Interesses:Programação em geral. Programo em PHP, ASP, PERL, VB, Delphi, C/C++, Java e com banco d dados<br><br>Gosto tb d ajudar. Se precisar d mim, basta postar uma msg no Forum! Se eu souber, te responderei...

Posted 06/02/2006, 07:30

Olá, wendel! Tudo bem?

Olha.. Provavelmente já existem diversos tópicos aqui no forum que respondem a esta questão. É bom dar uma procurada antes de perguntar, ok?

function difDate(data1,data2) {
    var d1=new Date(data1.substr(6,4), data1.substr(3,2)-1, data1.substr(0,2));
    var d2=new Date(data2.substr(6,4), data2.substr(3,2)-1, data2.substr(0,2));
    return Math.ceil((d2.getTime()-d1.getTime())/1000/60/60/24);
}

Um abraço,
Thales Medeiros.
Sucesso é ganhar dinheiro fazendo o que você faria de graça.

#3 wendel

wendel

    Turista

  • Usuários
  • 32 posts
  • Sexo:Não informado

Posted 06/02/2006, 22:28

Bom, queria dizer em primeiro lugar que procurei no fórum, e como não achei o que procurava, resolvi postar, mas sem problemas, irei olhar melhor antes do próximo.. a propósito, vc teria como montar isto em um form pra mim? ou seja, implementar, pois nao consegui fazer, se vc ou alguem fizer o favor pra mim, serei grato.
WLSistemas para Web
atendimento@wlsistemas.com
Wendel Lopes - Diretor

#4 wendel

wendel

    Turista

  • Usuários
  • 32 posts
  • Sexo:Não informado

Posted 06/02/2006, 23:10

SEGUE MEU CODIGO, SE ALGUEM CONSEGUIR ME AJUDAR... GRATO.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Valor do cheque</title>
</head>
<script type="text/javascript" language="javascript" src="datetimepicker.js"></script>
<script language="JavaScript">
<!--
  if (document.images)
  {
  calimg= new Image(16,16);
  calimg.src="images/cal.gif";
  }
//-->
</script>
<body>
<script language="JavaScript">
function soma(){

document.getElementById("numdias").value = '0'
document.getElementById("parcial").value = '0'
document.getElementById("total").value = '0'
var preco = parseFloat(document.getElementById("preco").value);
var juros = parseFloat(document.getElementById("juros").value);
var datacheque = parseFloat(document.getElementById("datacheque").value);
var dataatual = parseFloat(document.getElementById("dataatual").value);
var teste = difDate(datacheque, dataatual);
document.getElementById("numdias").value = teste;
document.getElementById("parcial").value = (datacheque - dataatual) / 30 * juros;
document.getElementById("totaljuros").value = preco-((100 - (((datacheque - dataatual) / 30) * juros)) * preco / 100);
document.getElementById("total").value = (100 - (((datacheque - dataatual) / 30) * juros)) * preco / 100;
}
</SCRIPT>
</head>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<form method="POST" action="">
  <tr>
    <td width="18%">
    <p style="margin-left: 15"><font face="Arial" style="font-size: 8pt">Valor
    do cheque :</font></td>
    <td width="82%"> <input type="text" id="preco" value="0" size="20"></td>
  </tr>
  <tr>
    <td width="18%">
    <p style="margin-left: 15"><font face="Arial" style="font-size: 8pt">Data
    atual :</font></td>
    <td width="82%">
<input type="Text" id="demo1" maxlength="25" size="9"><a href="java script:NewCal('demo1','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
</td>
  </tr>
  <tr>
    <td width="18%">
    <p style="margin-left: 15"><font face="Arial" style="font-size: 8pt">Data
    cheque :</font></td>
    <td width="82%">
<input type="Text" id="demo2" maxlength="25" size="9"><a href="java script:NewCal('demo2','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
</td>
  </tr>
  <tr>
    <td width="18%">
    <p style="margin-left: 15"><font face="Arial" style="font-size: 8pt">Taxa de
    Juros :</font></td>
    <td width="82%">
<select size="1" onblur="soma()" id="juros">
<option>selecione...</option>
<option value="4">4%</option>
<option value="5">5%</option>
<option value="6">6%</option>
<option value="7">7%</option>
<option value="8">8%</option>
<option value="9">9%</option>
<option value="10">10%</option>
</select></td>
  </tr>
  <tr>
    <td width="18%">
    <p style="margin-left: 15"><font face="Arial" style="font-size: 8pt">Dias :</font></td>
    <td width="82%"><b> <input type="text" id="numdias" size="20"></b></td>
  </tr>
  <tr>
    <td width="18%">
    <p style="margin-left: 15"><font face="Arial" style="font-size: 8pt">Juros
    do período :</font></td>
    <td width="82%"><b> <input type="text" id="parcial" size="2" maxlength="4"></b></td>
  </tr>
  <tr>
    <td width="100%" colspan="2"><hr size="1">
    </td>
  </tr>
  <tr>
    <td width="18%">
    <p style="margin-left: 15"><font face="Arial" style="font-size: 8pt">Total juros :</font></td>
    <td width="82%">
<b><input type="text" id="totaljuros" size="20"></b></td>
  </tr>
  <tr>
    <td width="18%">
    <p style="margin-left: 15"><font face="Arial" style="font-size: 8pt">Total&nbsp;líquido&nbsp;
    :</font></td>
    <td width="82%">
<b><input type="text" id="total" size="20"></b></td>
  </tr>
  <tr>
    <td width="18%">
    &nbsp;</td>
    <td width="82%">
&nbsp;</td>
  </tr>
  <tr>
    <td width="100%" colspan="2">
    <input type="reset" value="Novo calculo" name="B2"></td>
  </tr>
  </form>
</table>
</body>

</html>


Edição feita por: wendel, 06/02/2006, 23:10.

WLSistemas para Web
atendimento@wlsistemas.com
Wendel Lopes - Diretor

#5 Paulo André

Paulo André

    Why so serious?

  • Ex-Admins
  • 5114 posts
  • Sexo:Masculino
  • Localidade:Belo Horizonte - MG
  • Interesses:O.Q.F.J.?

Posted 07/02/2006, 06:58

ficaria assim em um formulário.... fiz separadamente, adaptá-lo em seu código é com vc ;)

<script>
function difDate(data1,data2) {
   var d1=new Date(data1.substr(6,4), data1.substr(3,2)-1, data1.substr(0,2));
   var d2=new Date(data2.substr(6,4), data2.substr(3,2)-1, data2.substr(0,2));
   alert( Math.ceil((d2.getTime()-d1.getTime())/1000/60/60/24) );
}
</script>

<form name="form" action="" method="POST">

Data 1: <input type="text" name="data1" value="01/08/2005"><br />
Data 2: <input type="text" name="data2" value="07/02/2006"><br />
<input type="button" value="sub" onclick="difDate(document.form.data1.value,document.form.data2.value);">

</form>

chamei-o pelo evento onclick co botão, e retornei um alerta... vc muda para o q vc quiser..

Flws...
(y)Até mais
Paulo André G Rodrigues,
ex-administrador Fórum WMO.


www.CanalDev.com.br

#6 Miguceamma

Miguceamma

    MiguPenjisse

  • Usuários
  • 13201 posts

Posted 18/09/2017, 05:26

Levitra Cuanto Tomar generic cialis Kamagra Oral Jelly 5gm Sildenafil
Viagra En Generique Propecia Vom Hausarzt Propecia Estrogenos
Viagra Bestellen Dhl <a href=http://cialtobuy.com>cialis</a> 2095 Albuterol Inhaler
Cialis Active Over The Counter cialis Prices Of Viagra
Canadian Pharmacy Accutan
Viagra Efectos Secundarios Pros Y Contras <a href=http://cialtobuy.com>cialis</a> Buy Cialis With No Perscription

#7 Miguceamma

Miguceamma

    MiguPenjisse

  • Usuários
  • 13201 posts

Posted 05/10/2017, 21:48

Achat De Ciprofloxacin En Ligne Generic Name For Amoxil Levitra Gunstig Mit Rezept viagra Walmart Viagra Price Prix Du Cialis 20 En Pharmacie
Adult Dose Amoxicillin viagra Levitra Online Buying Europe 247 Overnightpharmacy Com
Toronto Drug Store Pharmacy Propecia Does It Work Hair Growth Chewable Viagra cialis buy online Can I Purchase Elocon 5g

#8 Miguceamma

Miguceamma

    MiguPenjisse

  • Usuários
  • 13201 posts

Posted 02/11/2017, 23:11

Ed Pills At Walmart levitra order online Priligy Presentacion
Comprime Cytotec Acheter Du Cialis Viagra Sale No Prescription generic viagra Where To Buy Acticin Cialis Vente France Pharmacy Online Med

#9 papedlok

papedlok

    Ativo

  • Usuários
  • 350 posts
  • Sexo:Masculino
  • Localidade:Vacoas

Posted 03/11/2017, 06:30

Discounts! top skin care products progect12.jpg Products which fall under this return policy can be returned domestically, as long as they are unused and in the original packaging. No questions asked! If a product that falls under this guarantee is found to be counterfeit, you will get a full refund (shipping costs included). buy.png READ MORE HR202 Humidity Sensor Module ( $0.94 )ARTMOMO autumn and winter blackwhite sailor moon lunaartemis hand bag samantha vega handbag cat ear shoulder bag messenger bag ( 37.90 $)All-in-One Wireless Remote Control Kit for Arduino ( $7.57 )Fteroti Cognac Leather Flat Sandal ( 80.00 $)онлайн игра ангри берс бесплатнофильмы антиутопии +по книгамLilium applique camel suede fringe mini saddle bag ( 295.82 $) Tory Burchzombie avengers free взломаннаяbattlefield 3 premium edition ключWomen Genuine Leather Handbags Ladies Casual Simple Lichee Shoulder Bags Designer Handbags High Quality Purses Handbag Toe Black ( 45.98 $)Poslednee tango v ParizheGarofano Techno Suede Moccasin Shoe ( 164.50 $)Tissage Bresilienne Mocha Hair Products Peruvian Virgin Hair Straight Natural Black Straight Virgin Hair Human Hair Extensions ( 51.10 $)Free shipping diy handmade balanced armatured headphone four unit microdriver se535 ergonomic shell ( 143.10 $)Epoca White Dial and Black Leather Strap Mens Watch ( 198.00 $) 144bb.jpg
Discounts! best retail products

progect12.jpg
Products which fall under this return policy can be returned domestically, as long as they are unused and in the original packaging. No questions asked!
If a product that falls under this guarantee is found to be counterfeit, you will get a full refund (shipping costs included).

buy.png

READ MORE
Neoprene rubber belt drawing abdomen slimming cummerbund female thin body shaping waisttrainer black purple 4 color ( 24.97 $)
Mini black outdoor camping wallet knife credit card knife folding safely pocket campng knife tactical rescue ( 1.50 $)
Leten Fantasy Series 3 Dual Engine 10 Modes Vibration Electric Hip Male Masturbator w Strong Sucker, Men Adult Erotic Sex Toys ( 28.99 $)
Trump: New immigration order will be tailored
аккаунт origin +с battlefield 1
counter strike global offensive скачать торрент бесплатно
nike air force special field отзывы
Babe wire black leather womens sneaker ( 240.72 $) DSquared2
6pcsLOT BGA Precision ESD Tweezers Set, stainless steel anti-static tweezers Repair Tool Soldering Station Welding Assist ( 5.50 $)
Yuyue YY - 22 6 Hole Clarinet ( $2.75 )
купить обувь кеддо +в интернет магазине
Online toy store Toy.ru â buy baby toys at low prices with delivery to Russia
леомакс магазин
Chic rhinestoned v-shaped ring for women ( 5.01 $)
Alluring halter pure color string bikini set for women ( 10.91 $)


103.png

#10 Miguceamma

Miguceamma

    MiguPenjisse

  • Usuários
  • 13201 posts

Posted 25/11/2017, 08:43

Buy Cialis Online Chewable Viagra Soft Tabs cialis Antibiotics From Canada
Buy Zoloft Uk Online Lasix 40 mg levitra Cialis Generico Dosaggio What Are The Side Effects Of Zithromax Xenical Online Cheap
Antibiotics Without Prescription Canada Tadalafil Generico Prezzo Farmacia generic cialis Abortion Pill Fast Delivery
Cialis India Pharmacy Side Effect Of Keflex In Dogs cialis Rx Elife Keflex In Renal Impairment Comprar Viagra Sin Receta Contrareembolso
Kamagra Suisse Cetazolin And Keflex Suche Viagra Ch viagra Get Fluoxetine Pragmaten Ups Propecia Ways To Take Amoxil 500 Mg




0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq