tri_inn

tri_inn

  • NA
  • 1.2k
  • 223.7k

What we can do with date and time offset data

Jan 25 2017 4:44 AM

see here we store offset. so tell me what is the importance of storing offset data along with date and time ?

what we can do with offset data if we store ?

public void DemoDateTimeOffset()
{
DateTimeOffset offsetValue = new DateTime(2017, 1, 21, 4, 34, 0);
using (SqlConnection cn = new SqlConnection(myConnection))
{
string commandText = @" INSERT INTO DateTimeDemo (DateTimeExample,DateTimeOffsetExample)
VALUES (@DateTimeExample,@DateTimeOffsetExample)";
using (SqlCommand cmd = new SqlCommand(commandText, cn))
{
cmd.Parameters.AddWithValue("@DateTimeExample", DateTime.Now);
cmd.Parameters.AddWithValue("@DateTimeOffsetExample", offsetValue);
cn.Open();
cmd.ExecuteNonQuery();
}
}
}
 

thanks

Answers (4)