Skip to content

Instantly share code, notes, and snippets.

@pierslawson
Last active February 10, 2021 14:58
Show Gist options
  • Save pierslawson/6493e5d8aa2897808191c22dd491d42d to your computer and use it in GitHub Desktop.
Save pierslawson/6493e5d8aa2897808191c22dd491d42d to your computer and use it in GitHub Desktop.
Trying out date accuracy
using System;
using System.Globalization;
using System.Data.SqlTypes;
public class Program
{
public static void Main()
{
Console.WriteLine("2016,11, 13,7,11,58,837.0");
SqlDateTime dateToTestSql = new SqlDateTime(2016,11, 13,7,11,58,837.0);
Console.WriteLine(dateToTestSql.ToString());
Console.WriteLine(dateToTestSql.Value.Millisecond.ToString());
DateTime dateToTest = (DateTime)dateToTestSql;
Console.WriteLine(dateToTest.ToString("O"));
Console.WriteLine("");
Console.WriteLine("2016,11, 13,7,11,58,836.0");
dateToTestSql = new SqlDateTime(2016,11, 13,7,11,58,836.0);
Console.WriteLine(dateToTestSql.ToString());
Console.WriteLine(dateToTestSql.Value.Millisecond.ToString());
dateToTest = (DateTime)dateToTestSql;
Console.WriteLine(dateToTest.ToString("O"));
Console.WriteLine("");
Console.WriteLine("2016,11, 13,7,11,58,834.0");
dateToTestSql = new SqlDateTime(2016,11, 13,7,11,58,834.0);
Console.WriteLine(dateToTestSql.ToString());
Console.WriteLine(dateToTestSql.Value.Millisecond.ToString());
dateToTest = (DateTime)dateToTestSql;
Console.WriteLine(dateToTest.ToString("O"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment