Nikoxs Posted September 12, 2013 Report Share Posted September 12, 2013 HOLA BUENO E TRATADO MUCHAS COSAS Y BUSCADO Y BUSCADO Y NADA NO ENCUENTRO ALGO QUE ME AYUDE EN LO QUE NECESITO BUENO LES CUENTO ESTOY HACIENDO UN PROYECTO SOBRE ARRIENDO DE MAQUINARIA PESADA BUENO LO QUE NECESITO HACER O LA DUDA QUE TENGO ES COMO PUEDO SUMAR O ASER ALGO PARA SABER CUANDOS DIAS ESTARA OCUPADA LA MAQUINA QUE LOS VALORES LOS INGRESO EN LOS DATATIMEPICKER SON LAS FECHAS COMO POR EJEMPLO DESDE HOY HASTA 15/09/2013 QUIERO HACER QUE APAREZCAN LOS DIAS LA CANTIDAD DE DIAS QUE SON SI ME PUEDEN AYUDAR POR FAVOR ORIENTARME QUE ES LO QUE DEBO HACER DE ANTE MANO MUCHAS GRACIAS :tecnico: Link to comment Share on other sites More sharing options...
cañangasñangas Posted September 12, 2013 Report Share Posted September 12, 2013 (edited) compadre seria muuuy bueno y util que escribas con letras minusculas, ocupes puntos y comas, leer ese parrafo enverdad que fue una molestia... en cuanto a tu problema por que no traspasas la fechas a dias, ergo restas.... te dejo un pseudo codigo: String hoy = "11/11/2013"; String finRenta = "17/11/2013"; int char2int(char chr){ if(chr == "0"){ return 0; } if(chr == "1"){ return 1; } if(chr == "2"){ return 2; } if(chr == "3"){ return 3; } if(chr == "4"){ return 4; } if(chr == "5"){ return 5; } if(chr == "6"){ return 6; } if(chr == "7"){ return 7; } if(chr == "8"){ return 8; } if(chr == "9"){ return 9; } return 0; } int fecha2dias(String fecha){ int dias = char2int(fecha[0])*10+char2int(fecha[1])*1; int meses = char2int(fecha[3])*10+char2int(fecha[4])*1; int años = char2int(fecha[6])*1000+char2int(fecha[7])*100+char2int(fecha[8])*10+char2int(fecha[9])*1; if(años%4 == 0){ int losMeses[] = {30,29,30,31,30,31,30,31,30,31,30,31}; } else{ int losMeses[] = {30,28,30,31,30,31,30,31,30,31,30,31}; } int sumaMeses=0; for(int i=0;i<meses-1;i++){ sumaMeses+=losMeses[i]; } meses = sumaMeses; años *= 365; return dias+meses+años; } int diasQueFaltan = fecha2dias(finRenta)-fecha2dias(hoy);OJO este codigo funciona, si y solo si la fecha que se entrega a la funcion es de la forma dd/mm/aaaa ejemplo de una fecha mal introducida: 1/1/2014 ejemplo de una fecha bien introducida:01/01/2014 Ve como andas con algo como eso... Saludos :adios: Edited September 12, 2013 by cañangasñangas Link to comment Share on other sites More sharing options...
The Duke of Quakem Posted September 13, 2013 Report Share Posted September 13, 2013 (edited) Visual Basic .Net? Visual C# .Net? Se agradecerían mas detalles. De todas mangueras, puedes usar una variable del tipo timestamp para hacer cálculos entre variables datetime que son las que el control datetimepicker utiliza para almacenar la fecha/hora seleccionada. Edited September 13, 2013 by The Duke of Quakem Link to comment Share on other sites More sharing options...
taytuscorp Posted September 14, 2013 Report Share Posted September 14, 2013 si es en .net es facil datedif' The following statements set datTim1 to a Thursday' and datTim2 to the following Tuesday.Dim datTim1 As Date = #1/4/2001#Dim datTim2 As Date = #1/9/2001#' Assume Sunday is specified as first day of the week.Dim wD As Long = DateDiff(DateInterval.Weekday, datTim1, datTim2)Dim wY As Long = DateDiff(DateInterval.WeekOfYear, datTim1, datTim2)Saludos Link to comment Share on other sites More sharing options...
The Duke of Quakem Posted September 15, 2013 Report Share Posted September 15, 2013 (edited) Datediff sería ideal si es que está programando en VB.Net. Pero si es C#, DateDiff no existe en este último lenguaje, por lo que hay que usar una variable del tipo timestamp y combinarlo con el método DateTime.Substract para realizar la resta de 2 fechas y obtener la diferencia en el formato que el necesite (dias, meses, años, milisegundos, etc.) http://social.msdn.microsoft.com/Forums/es-ES/fac95a97-55be-43b0-b9af-da53c4005500/datediff-en-c Edited September 15, 2013 by The Duke of Quakem Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now