* (This is for the ISV database, so I'm kind of reverse engineering this and can't change) ...
How can I make the following date for converting int (visa / versa) to C # ...
So give the following:
5/17/2012
it is converted to int
77207
in the database.
At first I thought it was a Julian date, but it seems that it is not. I cheated on the Julian Date Question method , however this does not match. var date = ConvertToJulian(Convert.ToDateTime("5/17/2012"));
Console.WriteLine(date);
public static long ConvertToJulian(DateTime Date)
{
int Month = Date.Month;
int Day = Date.Day;
int Year = Date.Year;
if (Month < 3)
{
Month = Month + 12;
Year = Year - 1;
}
long JulianDay = Day + (153 * Month - 457)
/ 5 + 365 * Year + (Year / 4) -
(Year / 100) + (Year / 400) + 1721119;
return JulianDay;
}
Outputs 2456055
I use this SQL to convert:
SELECT Convert(date, CONVERT(CHAR,DATEADD(D, 77207, '1800-12-28'),101))
and that seems accurate. How can I do this conversion in C #? And can someone direct me to what standard it is based on, or is it just a random conversion. Thanks in advance.
source
share