Questions tagged [datetimeoffset]

DateTimeOffset is a data structure that encapsulates a DateTime value and the Offset from UTC that the value reflects. It is used to represent an instantaneous moment in time, while still capturing the perspective of the observer.

DateTimeOffset is a data structure that encapsulates a DateTime value and the Offset from UTC that the value reflects. It is used to represent an instantaneous moment in time, while still capturing the perspective of the observer.

Contrary to popular belief (and to much of the documentation) the offset provided does not represent a time zone. One might start with a time zone to obtain the offset, but it is a one-way function. You can not determine the time zone by the offset alone. For a better understanding of this, see this community wiki answer.

The preferred serialization format for this type of data is defined as part of the ISO-8601 specification.

  • Example: 1997-07-16T19:20:30+01:00

DateTimeOffset and similar structures are presented in:

Please update this list if you are aware of similar structures in other languages, frameworks, or databases

614 questions
6
votes
2 answers

How to convert .NET DateTimeOffset into Sql2008 DateTimeOffset

I'm not sure how to correctly format a .NET DateTimeOffset variable, as a string, for SqlServer 2008 to correct parse the value. currently, if I provide the default .ToString() value from a normal DateTimeOffset value, it errors. Here is a sample…
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
6
votes
3 answers

Invalid ID for ZoneOffset

I am trying to convert from java.sql.timestamp to OffsetDateTime so that i can return ISO8601 standard string in my rest api. I am using this code to convert from timestamp to OffsetDateTime public static OffsetDateTime…
Em Ae
  • 8,167
  • 27
  • 95
  • 162
6
votes
1 answer

using the datetimeoffset datatype with jTDS

jTDS currently doesn't support the datetimeoffset datatype introduced in SQL Server 2008. Can anybody suggest if there is a way to use the datetimeoffset type with jTDS?
Amiya
  • 61
  • 3
6
votes
2 answers

Sending DateTimeOffset from Android to .NET Web API

I am using Azure Mobile Apps SDK for Android. public class MyClass { public String Id; public String Code; public DateTimeOffset ClientCreatedAt; } MyClass myClass = new MyClass(); myClass.Id = "1234567890"; myClass.Code =…
Adam
  • 3,872
  • 6
  • 36
  • 66
6
votes
1 answer

Getting DateTimeOffset value from SQL 2008 to C#

I have a SQL 2008 table with a field called RecDate of type DateTimeOffset. For a given record the value is '2010-04-01 17:19:23.62 -05:00' In C# I create a DataTable and fill it with the results of SELECT RecDate FROM MyTable. I need to get the…
DarLom
  • 1,100
  • 2
  • 12
  • 30
6
votes
2 answers

DateTimeFormatter trouble with a pattern

I am writing a stock program that (so far) gets the data from "Markit on Demand" through a request such as this: http://dev.markitondemand.com/Api/v2/Quote/xml?symbol=aapl This returns the data in xml, with various measures of the stock (Symbol,…
Will Pike
  • 281
  • 4
  • 17
6
votes
1 answer

Strip Time Zone from a string using JavaScripty, Moment.js, etc?

Suppose I have a string like "01/22/2014 2:07:00 PM -08:00". I want to a) Format it in ISO 8601 with time offsets from UTC http://goo.gl/JTfAZq, so it becomes "2014-01-22T14:07:00-08:00" b) Strip out time offset part so it becomes "01/22/2014…
vkelman
  • 1,501
  • 1
  • 15
  • 25
6
votes
2 answers

Change only time part of a datetimeoffset in SQL

How can I set only the time portion of a SQL datetimeoffset variable? For example: DECLARE @date datetimeoffset = '2014-01-11 11:04:26 +02:00' I want to calculate two further datetimeoffsets: @startdate should be '2014-01-11 00:00:00…
Kev
  • 2,656
  • 3
  • 39
  • 63
6
votes
4 answers

The conversion of a datetimeoffset data type to a datetime data type resulted in an out-of-range value

Using SQL Server 2008.I have a table called User which has a column LastLogindata with datetimeoffset datatype The following query works on production server but not on replication server. select top 10 CAST(LastLoginDate AS DATETIME) from User. I…
paraaku chiraaku
  • 61
  • 1
  • 1
  • 3
6
votes
3 answers

How do I Increment an NSDate object in Objective-C

I want to take the next day by giving the current date The code i used as follows +(NSDate *)getForDays:(int)days fromDate:(NSDate *) date { NSTimeInterval secondsPerDay = 24 * 60 * 60 * days; return [date…
Hasitha
  • 61
  • 1
  • 3
6
votes
2 answers

DateTimeOffsetAdapter interfering with WCF serialization of DateTimeOffset objects

I have a WCF service reference (= client proxy) generated by Visual Studio 2008 (.net 3.5 sp1). The generated code contains a data contract with DateTimeOffset properties so naturally VS decorated it with KnowTypeAttribute(System.DateTimeOffset).…
urig
  • 16,016
  • 26
  • 115
  • 184
5
votes
3 answers

convert datetime from one offset to another offset

How to convert 2019-09-05T11:31:34.059Z this DateTime to offset 260. database:mssql, datatype:datetimeoffset(7). As one can identify current time-offset then how to convert the given date to this time-offset
akshay bagade
  • 1,169
  • 1
  • 11
  • 24
5
votes
1 answer

What is valid RFC1123 date format

I am working on a service which returns expires header. The service will be working across different timezone. So we need a way to return other timezones than GMT. I know that the http header have to follow RFC1123 standard date format. So the…
Newbee
  • 1,379
  • 2
  • 16
  • 36
5
votes
1 answer

SQL ISDATE returns false for string formatted as ISO w/timezone (127)

I'm attempting to take a string, determine if it is a date (date time or time) and then convert it to the respective data type with the SQL server convert format constants. However, I'm having a lot of trouble with 127 "yyyy-mm-ddThh:mi:ss.mmmZ" in…
Adam James
  • 3,833
  • 6
  • 28
  • 47
5
votes
3 answers

Cloud Firestore: Storing and querying for today's date over multiple UTC offsets?

I'm writing a web app using Firestore that needs to be able to show "Today's Popular Posts" and I'm having trouble getting the queries right when considering users in different timezones. The dates are stored in the DB as UTC 0, then adjusted to the…
saricden
  • 2,084
  • 4
  • 29
  • 40