# Google Cloud Spanner v1 API - Struct SpannerDate (5.13.0-beta07)

5.13.0-beta07 5.13.0-beta06 5.12.0 (latest) 5.11.0 5.10.0 5.9.0 5.8.0 5.7.0 5.6.0 5.5.0 5.4.0 5.3.0 5.2.0 5.1.0 5.0.0 4.6.0 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.15.1 3.14.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0

    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.

## Implements

[IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate), [IComparable](https://learn.microsoft.com/dotnet/api/system.icomparable-1)[SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate), [IComparable](https://learn.microsoft.com/dotnet/api/system.icomparable)

## Inherited Members

[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype)

## Namespace

[Google.Cloud.Spanner.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1)

## Assembly

Google.Cloud.Spanner.V1.dll

## Constructors

### SpannerDate(int, int, int)

    public SpannerDate(int year, int month, int day)

Initializes a new instance of the [SpannerDate](https://docs.cloud.google.com/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.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `year` | `https://learn.microsoft.com/dotnet/api/system.int32` The year (in the range 1-9999 inclusive). |
| `month` | `https://learn.microsoft.com/dotnet/api/system.int32` The month (in the range 1-12 inclusive). |
| `day` | `https://learn.microsoft.com/dotnet/api/system.int32` The day (1 through the number of days in `month`). |

## Properties

### Day

    public int Day { get; }

Gets the day of the month of the date represented by this instance.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

### MaxDate

    public static SpannerDate MaxDate { get; }

Gets the latest possible date that can be represented by [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` |   |

### MinDate

    public static SpannerDate MinDate { get; }

Gets the earliest possible date that can be represented by [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` |   |

### Month

    public int Month { get; }

Gets the month component of the date represented by this instance.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

### Year

    public int Year { get; }

Gets the year component of the date represented by this instance.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

## Methods

### AddDays(int)

    public SpannerDate AddDays(int days)

Returns a new instance of the [SpannerDate](https://docs.cloud.google.com/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.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `days` | `https://learn.microsoft.com/dotnet/api/system.int32` The number of days to be added. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` | A new instance of the SpannerDate value that is the sum of the date represented by this instance and the number of days represented by `days`. |

### CompareTo(SpannerDate)

    public int CompareTo(SpannerDate other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

### FromDateTime(DateTime)

    public static SpannerDate FromDateTime(DateTime dateTime)

Returns a SpannerDate instance that is set to the date part of the specified DateTime.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `dateTime` | `https://learn.microsoft.com/dotnet/api/system.datetime` The DateTime value. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` | The SpannerDate instance |

### GetHashCode()

    public override int GetHashCode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

**Overrides** [ValueType.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.valuetype.gethashcode)

### Parse(string)

    public static SpannerDate Parse(string text)

Parses a textual representation in yyyy-MM-dd format as a [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `text` | `https://learn.microsoft.com/dotnet/api/system.string` The text to parse. Must not be null. Must be in yyyy-MM-dd format only. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` | The parsed value. |

**Remarks**
`text` must be a representation of a date value in yyyy-MM-dd format which can be represented by [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.formatexception` | The value could not be parsed as a [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate). |

### ToDateTime()

    public DateTime ToDateTime()

Converts 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).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.datetime` | The DateTime value. |

### ToString()

    public override string ToString()

Returns the ISO 8601 representation (yyyy-MM-dd) of the date represented by this instance.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | The ISO 8601 string representation of the date represented by this instance. |

**Overrides** [ValueType.ToString()](https://learn.microsoft.com/dotnet/api/system.valuetype.tostring)

### TryParse(string, out SpannerDate)

    public static bool TryParse(string text, out SpannerDate value)

Attempts to parse a textual representation of date in yyyy-MM-dd format as [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `text` | `https://learn.microsoft.com/dotnet/api/system.string` The text to parse. Must not be null. Must be in yyyy-MM-dd format only. |
| `value` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The parsed value, or 0 on failure. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `true` if `text` was parsed successfully; `false` otherwise. |

**Remarks** See [Parse(string)](https://docs.cloud.google.com/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
[Parse(string)](https://docs.cloud.google.com/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.

## Operators

### operator ==(SpannerDate, SpannerDate)

    public static bool operator ==(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether the values of two [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) objects are equal.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The first value to compare. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The second value to compare. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `true` if the two arguments are equal; `false` otherwise. |

### explicit operator DateTime(SpannerDate)

    public static explicit operator DateTime(SpannerDate value)

Performs an explicit conversion from [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) to [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The SpannerDate value. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.datetime` | The result of the conversion. |

### explicit operator SpannerDate(DateTime)

    public static explicit operator SpannerDate(DateTime value)

Performs an explicit conversion from [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) to [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://learn.microsoft.com/dotnet/api/system.datetime` The DateTime value. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` | The result of the conversion. |

### operator \>(SpannerDate, SpannerDate)

    public static bool operator >(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether a [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) value is greater than another [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The value to compare with `rhs`. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The value to compare with `lhs`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `true` if `lhs` is greater than `rhs`; otherwise, `false`. |

### operator \>=(SpannerDate, SpannerDate)

    public static bool operator >=(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether a [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) value is greater than or equal to another [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The value to compare with `rhs`. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The value to compare with `lhs`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `true` if `lhs` is greater than or equal to `rhs`; otherwise, `false`. |

### operator !=(SpannerDate, SpannerDate)

    public static bool operator !=(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether the two [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) objects have unequal values.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The first value to compare. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The second value to compare. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `false` if the two arguments are equal; `true` otherwise. |

### operator \<(SpannerDate, SpannerDate)

    public static bool operator <(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether a [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) value is less than another [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The value to compare with `rhs`. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The value to compare with `lhs`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `true` if `lhs` is less than `rhs`; otherwise, `false`. |

### operator \<=(SpannerDate, SpannerDate)

    public static bool operator <=(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether a [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate) value is less than or equal to another [SpannerDate](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The value to compare with `rhs`. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SpannerDate` The value to compare with `lhs`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `true` if `lhs` is less than or equal to `rhs`; otherwise, `false`. |