Convert float, double, or single value to DateTime

0

I was having Cast problems when I was running a lambda and serializing to the service. Well, the solution was to pass everything to String and I did it. On the other side (Android App) I get and do what has to be done. Well, it turns out that this client has their dates loaded into the database as a float, like this one ( 79018 ). It turns out that when I give a float.Parse(data_string) and then a Convert.ToDateTime(floatvalue) , it gives the cast error saying that you can not cast Double to Single. If I post to single, continues the error, the same problem I was having before, which generated me some posts here. How do I make this value into DateTime?

private void listaLibera_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var libera = e.SelectedItem as Liberacao;
            DateTime datas = Convert.ToDateTime(float.Parse(libera.DataLib));

            lblTipoVenda.Text = "Tipo de Venda: " + libera.TipoVenda;
            //lblVencimento.Text = "Vencimento: " + (Convert.ToDateTime(libera.Vendedor)).ToString("dd/mm/yyyy");
            lblJuros.Text = "Juros: " + libera.Juros.ToString();
            lblEntrada.Text = "Entrada: " + libera.Entrada;
            lblAcrescimo.Text = "Acréscimo: " + libera.Acrescimo;
            lblDesconto.Text = "Desconto: " + datas.ToString("dd/mm/yyyy");
        }

I got the literal value and tried to convert and continue the cast error, like this: Convert.ToDateTime(79018.0f) .

    
asked by anonymous 05.09.2017 / 16:05

1 answer

1

According to this gist , the date on Clarion considers the number of days that have passed since 12/28/1800. So following the logic, it will give the date as follows:

new DateTime(1800, 12, 28).AddDays(79018).ToShortDateString();

Correct me if you're wrong, please.

    
06.09.2017 / 22:59