2
I have two dates: DataAcesso
and DataAtual
of the kind DateTime
. I have one more field called TempoAtualizacaoAutomatica
typo byte
.
I need to subtract these dates and compare the result with TempoAtualizacaoAutomatica
.
Condition is: If "dates" are less than TempoAtualizacaoAutomatica
"On", otherwise "Off".
How do I do that?
I’ve tried the first part of that rule like this:
TimeSpan final = Convert.ToDateTime("19/03/2007 12:30").Subtract(Convert.ToDateTime("19/03/2007 12:00"));
But you didn’t get what I wanted.
As I’m doing this at MVC, this part should evidently be on Controllers, right?
Thank you!
To models.
Painelchamada
public string Descricao { get; set; }
public bool FlagEstacaoI { get; set; }
public bool FlagEstacaoT { get; set; }
public bool FlagEstacaoD { get; set; }
public byte QtdeChamadasListadas { get; set; }
public byte QtdeChamadasFornecedor { get; set; }
public bool FlagExibirDesenhos { get; set; }
public string UrlChamadaAlerta { get; set; }
public byte TempoAtualizacaoAutomatica { get; set; }
public byte QtdeAcessosSimultaneos { get; set; }
public System.Guid Guid { get; set; }
public bool FlagBloqueioPainel { get; set; }
Painelchamada Log Access
public int IdEmpresa { get; set; }
public int IdPainelChamada { get; set; }
public long Id { get; set; }
public System.DateTime DataAcesso { get; set; }
public string Ip { get; set; }
public string CabecalhoHttp { get; set; }
public virtual PainelChamada PAINEL_CHAMADA { get; set; }
ON means: panel is working.
Off: panel is disabled.
There are two classes. Note that I will need to set items of one and the other for this method to work.
What is the condition to be met? What is the rule for variable Tempoatualizacaoautomatica be "ON" or "OFF"?
– Laerte
If the comparison of dates is less than Tmepoupdatedautomatica. Example: Subtracting the dates I got 5 I will compare with Timetimethe Utomatica of my Call and if it is smaller will be On
– chewie
This is important: of what type is the variable and what measure do you represent in Tempoatualizaoautomatica? Days, hours, minutes, a
TimeSpan
?– iuristona
But Tempoatualizaoautomatica is not byte type?
– Laerte
Exactly a Timespan... The code was generated automatically and Tempoatualizacaoautomatica is a byte and for the use case itself it is necessary to respect this
– chewie
TempoAtualizacaoAutomatica
represents what? Days, hours, minutes, seconds or some other unit of time?– Leonel Sanches da Silva
Represents Hours
– chewie
@Take a look at [tour]. You can accept an answer if it solved your problem. You can vote for all the posts on the site as well. Did any help you more? You need something to be improved?
– Maniero
@I don’t understand why you
TempoAtualizacaoAutomatica
is with type 'byte' need to know this to know how to convert this byte to a value (integer, double, or timeSpan) to create an algorithm that suits you.– Renan Degrandi