I would like to convert double to datetime.
This is not a conversion from Excel. I have a double view of seconds and just want to represent it as time in minutes and seconds.
121.0005 = 2:01 min
Use TimeSpan:
TimeSpan
double seconds = 121.0005; TimeSpan sp = TimeSpan.FromSeconds(seconds); Console.Write(string.Format("{0} mins", sp.ToString(@"m\:ss")));
Instead DateTimeyou need to TimeSpan, since your input represents a time value, not Date.
DateTime
Date
Use the method TimeSpan.FromSeconds.
TimeSpan.FromSeconds
double sec = 121.0005; TimeSpan ts = TimeSpan.FromSeconds(sec);
Source: https://habr.com/ru/post/1527552/More articles:Show preview in Android Studio in preview - androidBootstrap-Tour with AngularJS - angularjsSencha cmd 4 adding css and js - cmdXSLT if - attribute equals string - xmlHow to create custom SASS in ExtJS for compilation using Sencha CMD - extjsHow to get triangles from triangulation 3D Delaunay - matlabExcel word frequency counting - excel-vbaIn sleep mode, how to programmatically set the transaction isolation level or how to create two transactions with different isolation levels - javaRunning a shell script inside another shell script with another user - linuxAuthentication when connecting to a MongoDB server instance using Java - javaAll Articles