help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ayuda


From: James Sherman Jr.
Subject: Re: ayuda
Date: Mon, 17 Oct 2011 09:12:26 -0400

On Mon, Oct 17, 2011 at 12:49 AM, rolando rios cruz <address@hidden> wrote:
See I have this code
--------------------------------------------------


close all
clear all
clc
%define fecha de inicio dd/mm/aaaa
dts = input ("Introduce la fecha de pedido en dd-mm-yyyy : ", "s");
dt1 = datevec(dts, "dd-mm-yyyy ");
dts = input ("Introduce la fecha de surtido en dd-mm-yyyy : ", "s");
dt2 = datenum(dts, "dd-mm-yyyy ");
dts = input ("Introduce la hora de pedido en hh:mm : ", "s");
dt3 = datanum(dts, "hh:mm ");
dts = input ("Introduce la hora de surtido en hh:mm : ", "s");
dt4 =datavec(dts, "hh:mm ");
difference = datenum(dt2) - datenum(dt1);
diasdiferencia=difference;
diasinhabiles=(diasdiferencia/7)*2;
diasdemora=diasdiferencia-diasinhabiles-21;
diasdemora=round(diasdemora);
tarifaendolares=diasdemora*50
difference= datenum(dt4) - datenum(dt3);
horademora=difference


-------------------------------------------------
but make mistake
I need calculate days with hours between two times
help me please¡¡¡


I can't follow your code, but if you want to do the input in two parts (instead of one full date string), I'd suggest appending each date string then having just one call to datevec.  I believe the error in your code is that when you call datevec with:
dt4 =datavec(dts, "hh:mm ");
It assumes that the year, month and day are the current ones, which, obviously is not what you want in your case.

dstr1a = input("Enter the date (yyyy-mm-dd)", "s");
dstr1b = input("Enter the time (HH:MM)", "s");
full_datestr = [dstr1a, " ", dstr1b];
datev1 = datevec( full_datestr, "yyyy-mm-dd HH:MM");
d1 = datenum(datev1);

Either that or you could have them enter each field separately (year, minute, day, etc) then call datenum with multiple arguments instead of with the date vector.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]