Command similar to sql convert in C #

0

I have a return in sql that comes as something like 52,451541554 .

This return, if I convert it with the command convert(datetime, DtCriacao, 103) of sql it turns into a date format, but I need to get it myself, which this time came from an excel file and convert it to date format or string .

I have no idea how to do this kind of conversion in C #.

Thank you

    
asked by anonymous 04.04.2018 / 13:40

1 answer

1

Considering that the value received from bd is a timestamp , you need to convert it to date and then display it in the format corresponding to% > sql ( 103 ):

string valorSql = "52,451541554";
System.DateTime data = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
data = data.AddSeconds(valorSql);
string retorno = data.ToString("dd/M/yyyy", CultureInfo.InvariantCulture);
    
04.04.2018 / 13:57