datetimeoffset

Convert DateTimeOffset to DateTime and add offset to this DateTime

淺唱寂寞╮ 提交于 2020-07-05 05:24:16
问题 I have DateTimeOffset : DateTimeOffset myDTO = DateTimeOffset.ParseExact( "2015/01/15 17:37:00 -0500", "yyyy/MM/dd HH:mm:ss zzz", CultureInfo.InvariantCulture); Console.WriteLine(myDTO); //result=> "1/15/2015 17:37:00 -05:00" How convert to DateTime and add this offset "-0500" in the resulted DateTime //desired result=>" 1/15/2015 22:37:00 " 回答1: Use DateTimeOffset.UtcDateTime: DateTime utc = myDTO.UtcDateTime; // 01/15/2015 22:37:00 回答2: You do not have to add the offset to the time when

How to affect timezone when serializing DateTimeOffset with System.Text.Json?

生来就可爱ヽ(ⅴ<●) 提交于 2020-06-01 06:52:06
问题 Task to solve: Given a DateTimeOffset , its value has a particular Offset. I would like to serialize it with the exact form as it was represented, with that exact date and time value and exact same Offset value Problem Currently when serializing the moment is correct, but the formatted serialized version of the point in time is converted to the offset which is according to the current timezone. (This way although the point in time remains correct, but the original offset information lost)

Python: third Friday of a month

若如初见. 提交于 2020-03-17 04:37:01
问题 I am a rookie python programmer and I need to write a script to check if a given date (passed as a string in the form 'Month, day year') is the third Friday of the month. I am using Python 2.7. For example, these dates can help you better understand my problem. Have a yearly calendar at hand. input ---> output 'Jan 18, 2013' ---> True 'Feb 22, 2013' ---> False 'Jun 21, 2013' ---> True 'Sep 20, 2013' ---> True I just want to use standard classes provided by the language, like time, datetime,

C# Add 1 day in specific TimeZone to DateTimeOffset

亡梦爱人 提交于 2020-02-15 06:21:24
问题 I have an instance of DateTimeOffset and I need to add 1 day to it in specific TimeZone (W. Europe Standard Time) taking into account daylight saving rules (so it might result in Offset change). How can I do it without 3rd party libraries? Verifiable example: using System; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UnitTestProject { [TestClass] public class TimeZoneTests { [TestMethod] public void DateTimeOffsetAddDays_DaylightSaving_OffsetChange() { var timeZoneId = "W.

C# Add 1 day in specific TimeZone to DateTimeOffset

我怕爱的太早我们不能终老 提交于 2020-02-15 06:20:13
问题 I have an instance of DateTimeOffset and I need to add 1 day to it in specific TimeZone (W. Europe Standard Time) taking into account daylight saving rules (so it might result in Offset change). How can I do it without 3rd party libraries? Verifiable example: using System; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UnitTestProject { [TestClass] public class TimeZoneTests { [TestMethod] public void DateTimeOffsetAddDays_DaylightSaving_OffsetChange() { var timeZoneId = "W.

Does DbFunctions.TruncateTime behave differently in different server time zones?

老子叫甜甜 提交于 2020-01-15 08:22:08
问题 I'm not sure that my question Title is perfect - so please allow me to explain a little further. Here's a snapshot of some test data: Here's my code: Function TestDb() As ActionResult Dim clientLocId As Integer = 23 Dim showDate As New Date showDate = New Date(2015, 8, 14) 'showDate = New Date(2015, 9, 22) 'showDate = New Date(2015, 9, 27) Dim orderRecs = db.Orders.Where(Function(x) x.ClientLocationId = clientLocId AndAlso x.OrderNumber IsNot Nothing _ AndAlso x.DateCompletedUtc IsNot Nothing

How to migrate DateTime values to DateTimeOffset in SQL Server?

拜拜、爱过 提交于 2020-01-11 04:32:10
问题 Given a SQL table with a DateTime column and approx 100k rows of various dates (local time PST values) from the past 3 years, what is the best strategy to migrate those column values to DateTimeOffset to "add" the missing utc tz offset info? The existing DateTime values have been stored without any time zone/utc offset details. The dates stored are always representative of Pacific Time (-800 or -700 depending on Daylight Saving Time). Goal is to retroactively add the tz offset to all existing

Unable to insert datetimeoffset value using Spring Boot, on SQL Server 2016

回眸只為那壹抹淺笑 提交于 2020-01-06 07:12:34
问题 I have this POJO: public class SomeEntity { private String recordName; private Instant recordDatetime; public SomeEntity(String recordName, Instant recordDateTime) { this.recordName = recordName; this.recordDateTime = recordDateTime; } // Getters and Setters } ...and this corresponding database table defined in a SQL Server 2016 database: CREATE TABLE [dbo].[some_entities]( [record_name] [nvarchar](255) NOT NULL, [record_datetime] [datetimeoffset](7) NOT NULL, CONSTRAINT [PK_some_entities]

Unable to insert datetimeoffset value using Spring Boot, on SQL Server 2016

半腔热情 提交于 2020-01-06 07:09:24
问题 I have this POJO: public class SomeEntity { private String recordName; private Instant recordDatetime; public SomeEntity(String recordName, Instant recordDateTime) { this.recordName = recordName; this.recordDateTime = recordDateTime; } // Getters and Setters } ...and this corresponding database table defined in a SQL Server 2016 database: CREATE TABLE [dbo].[some_entities]( [record_name] [nvarchar](255) NOT NULL, [record_datetime] [datetimeoffset](7) NOT NULL, CONSTRAINT [PK_some_entities]

How to format SQL Server DateTimeOffset and move to Oracle using OracleBulkCopy

痴心易碎 提交于 2020-01-04 21:34:54
问题 I'm trying to move SQL Server DateTimeOffset or Oracle using OracleBulkCopy. For DateTimeOffset(1) the target data type is Timestamp(1) With Time Zone. If I do a select of the DateTimeOffset(1) column on SQL Server I receive the following: 2007-05-08 12:35:29.1 +12:15 When I try to move this to Oracle I receive: ORA-01843: not a valid month It makes sense and I believe the month needs to first, but If I run INSERT into MyOracleTable values('2007-05-08 12:35:29.1 +12:15') I can insert just