Calculating the average of different dates in different years [duplicate] - c#

This question already has answers here:
How to find an average date/time in the array of DateTime values
(7 answers)
Closed 8 years ago.
I need to calculate the average the following observed dates:
1/7/2010
15/7/2011
17/6/2012
3/7/2013
How can I do that in asp.net or any other language. If there is any formula to do that.

You need to convert it to Ticks (this will convert it to System.Int64) and then do the average of them all.
See the following answer: https://stackoverflow.com/a/16683441/643761

Related

Converting DateTime.Now.Ticks.ToString("x"); back to human readable timestamp [duplicate]

This question already has answers here:
How can I convert ticks to a date format?
(4 answers)
Convert integer to hexadecimal and back again
(11 answers)
Closed 2 years ago.
I have a script that creates data and stores the with a name that contains the output of DateTime.Now.Ticks.ToString("x"); I now need to convert this value back to a human readable time in order to figure out when the data was generated for a report but I cant find any tools or equations to do this anywhere. All help appreciated.
some values i'm trying to convert:
8d84e63114d60d2
8d84e6645daa831
8d84e67c9ba1367
8d84e6993166d49

How to generate a random number that is different from an existing number? [duplicate]

This question already has answers here:
How do I generate a random integer in C#?
(31 answers)
How to get a random number from a range, excluding some values
(11 answers)
Select from a range but exclude certain numbers [duplicate]
(7 answers)
Closed 5 years ago.
I know this question sounds like a duplicate, but I haven't found an answer to it yet. Let me know, thanks.
For example:
a = 50
b = random
But b can never be the same as a

Number Format in c# [duplicate]

This question already has answers here:
Two Decimal places using c#
(13 answers)
Closed 5 years ago.
I am trying to formatting decimal number in c#.I tried ToString("N") and String.Format but it does not work because Total is defined as a decimal in the database.For example, If the total is 93.7567, then it should be 93.76. Here is the code:
Total = g.Sum(c => c.Total)
You could use Math.Round() Method.
total = Math.Round(total,2); // 93.7567 becomes 93.76.
You can try decimalvalue.ToString("#.##"); or decimalvalue.ToString("F")

Math Round in VS C# [duplicate]

This question already has answers here:
How do I display a decimal value to 2 decimal places?
(19 answers)
Closed 5 years ago.
so I have the following problem I'm trying to output 2 numbers after the decimal comma but it doesn't output it with 2 numbers only when I have zero or more than one zero at the end of the number.
Console.WriteLine(Math.Round(s * 0.07, 2));
here's how I did it.
You might want:
Console.WriteLine($"{s:N2}");

C# Double.ToString() [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Custom numeric format string to always display the sign
To format a double to certain precision in C# I write this:
d.ToString("#0.00");
What if I want to force a the sign to appear..
e.g
+2.54 and -2.54
Hope this will work.
YourDoublenumber.ToString("+#;#");

Categories

Resources