public readonly struct SpannerDate : IEquatable<SpannerDate>, IComparable<SpannerDate>, IComparable
Reference documentation and code samples for the Google Cloud Spanner v1 API struct SpannerDate.
The SpannerDate type represents a logical calendar date, independent of time zone.
Represents dates with values ranging from January 1, 0001 A.D through December 31, 9999 A.D. in the Gregorian calendar.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe latest version of the Google Cloud Spanner v1 API \u003ccode\u003eSpannerDate\u003c/code\u003e is 5.0.0-beta05, with several prior versions available including 5.0.0-beta04, 4.6.0, and multiple 3.x versions.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSpannerDate\u003c/code\u003e represents a date in the Gregorian calendar ranging from January 1, 0001 A.D. to December 31, 9999 A.D., independent of time zones.\u003c/p\u003e\n"],["\u003cp\u003eThis \u003ccode\u003eSpannerDate\u003c/code\u003e struct includes methods for parsing dates from strings in yyyy-MM-dd format, converting to and from \u003ccode\u003eDateTime\u003c/code\u003e, adding days, and comparing dates.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSpannerDate\u003c/code\u003e has static properties for \u003ccode\u003eMaxDate\u003c/code\u003e and \u003ccode\u003eMinDate\u003c/code\u003e, representing the latest and earliest possible dates in this struct, respectively.\u003c/p\u003e\n"],["\u003cp\u003eThe SpannerDate has properties for accessing the day, month, and year of the date that is represented by an instance of the struct.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Spanner v1 API - Struct SpannerDate (5.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [5.1.0 (latest)](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/5.0.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.6.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.5.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.4.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.3.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.2.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.1.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.0.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.15.1/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.14.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.13.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.12.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.11.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.10.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.9.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.8.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.7.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.6.0/Google.Cloud.Spanner.V1.SpannerDate)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.5.0/Google.Cloud.Spanner.V1.SpannerDate) \n\n public readonly struct SpannerDate : IEquatable\u003cSpannerDate\u003e, IComparable\u003cSpannerDate\u003e, IComparable\n\nReference documentation and code samples for the Google Cloud Spanner v1 API struct SpannerDate.\n\nThe SpannerDate type represents a logical calendar date, independent of time zone.\nRepresents dates with values ranging from January 1, 0001 A.D through December 31, 9999 A.D. in the Gregorian calendar. \n\nImplements\n----------\n\n[IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate), [IComparable](https://learn.microsoft.com/dotnet/api/system.icomparable-1)[SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate), [IComparable](https://learn.microsoft.com/dotnet/api/system.icomparable) \n\nInherited Members\n-----------------\n\n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype)\n\nNamespace\n---------\n\n[Google.Cloud.Spanner.V1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Spanner.V1.dll\n\nConstructors\n------------\n\n### SpannerDate(int, int, int)\n\n public SpannerDate(int year, int month, int day)\n\nInitializes a new instance of the [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) structure to the specified year, month, and day in the Gregorian calendar.\n\nProperties\n----------\n\n### Day\n\n public int Day { get; }\n\nGets the day of the month of the date represented by this instance.\n\n### MaxDate\n\n public static SpannerDate MaxDate { get; }\n\nGets the latest possible date that can be represented by [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).\n\n### MinDate\n\n public static SpannerDate MinDate { get; }\n\nGets the earliest possible date that can be represented by [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).\n\n### Month\n\n public int Month { get; }\n\nGets the month component of the date represented by this instance.\n\n### Year\n\n public int Year { get; }\n\nGets the year component of the date represented by this instance.\n\nMethods\n-------\n\n### AddDays(int)\n\n public SpannerDate AddDays(int days)\n\nReturns a new instance of the [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) that adds the specified number of days to the value of this instance.\n\n### CompareTo(SpannerDate)\n\n public int CompareTo(SpannerDate other)\n\n### FromDateTime(DateTime)\n\n public static SpannerDate FromDateTime(DateTime dateTime)\n\nReturns a SpannerDate instance that is set to the date part of the specified DateTime.\n\n### GetHashCode()\n\n public override int GetHashCode()\n\n**Overrides** \n[ValueType.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.valuetype.gethashcode)\n\n### Parse(string)\n\n public static SpannerDate Parse(string text)\n\nParses a textual representation in yyyy-MM-dd format as a [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).\n\n**Remarks** \n\n`text` must be a representation of a date value in yyyy-MM-dd format which can be represented by [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).\n\n### ToDateTime()\n\n public DateTime ToDateTime()\n\nConverts the value of this SpannerDate instance to the [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) of kind [Unspecified](https://learn.microsoft.com/dotnet/api/system.datetimekind#system-datetimekind-unspecified).\n\n### ToString()\n\n public override string ToString()\n\nReturns the ISO 8601 representation (yyyy-MM-dd) of the date represented by this instance.\n\n**Overrides** \n[ValueType.ToString()](https://learn.microsoft.com/dotnet/api/system.valuetype.tostring)\n\n### TryParse(string, out SpannerDate)\n\n public static bool TryParse(string text, out SpannerDate value)\n\nAttempts to parse a textual representation of date in yyyy-MM-dd format as [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).\n\n**Remarks** \nSee [Parse(string)](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate#Google_Cloud_Spanner_V1_SpannerDate_Parse_System_String_) for format details. This method will return `true` if and only if\n[Parse(string)](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate#Google_Cloud_Spanner_V1_SpannerDate_Parse_System_String_) would return without an exception.\n\nOperators\n---------\n\n### operator ==(SpannerDate, SpannerDate)\n\n public static bool operator ==(SpannerDate lhs, SpannerDate rhs)\n\nReturns a value that indicates whether the values of two [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) objects are equal.\n\n### explicit operator DateTime(SpannerDate)\n\n public static explicit operator DateTime(SpannerDate value)\n\nPerforms an explicit conversion from [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) to [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime).\n\n### explicit operator SpannerDate(DateTime)\n\n public static explicit operator SpannerDate(DateTime value)\n\nPerforms an explicit conversion from [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) to [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).\n\n### operator \\\u003e(SpannerDate, SpannerDate)\n\n public static bool operator \u003e(SpannerDate lhs, SpannerDate rhs)\n\nReturns a value that indicates whether a [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) value is greater than another [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).\n\n### operator \\\u003e=(SpannerDate, SpannerDate)\n\n public static bool operator \u003e=(SpannerDate lhs, SpannerDate rhs)\n\nReturns a value that indicates whether a [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) value is greater than or equal to another [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).\n\n### operator !=(SpannerDate, SpannerDate)\n\n public static bool operator !=(SpannerDate lhs, SpannerDate rhs)\n\nReturns a value that indicates whether the two [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) objects have unequal values.\n\n### operator \\\u003c(SpannerDate, SpannerDate)\n\n public static bool operator \u003c(SpannerDate lhs, SpannerDate rhs)\n\nReturns a value that indicates whether a [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) value is less than another [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).\n\n### operator \\\u003c=(SpannerDate, SpannerDate)\n\n public static bool operator \u003c=(SpannerDate lhs, SpannerDate rhs)\n\nReturns a value that indicates whether a [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) value is less than or equal to another [SpannerDate](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate)."]]