Indicates how to choose the timestamp at which to read the data for Cloud Spanner read-only transactions.
If your application can tolerate some staleness when reading data, you can use a stale read,
which can execute much faster when compared to reading the latest data.
The types of timestamp bounds are:
Strong (the default): read the latest data.
Bounded staleness: read a version of the data that's no staler than a bound.
Exact staleness: read the version of the data at an exact timestamp.
public static TimestampBound OfExactStaleness(TimeSpan duration)
Executes all reads at a timestamp that is duration
old. The timestamp is chosen soon after the read is started.
Guarantees that all writes that have committed more than the
specified number of seconds ago are visible. Because Cloud Spanner
chooses the exact timestamp, this mode works even if the client's
local clock is substantially skewed from Cloud Spanner commit
timestamps.
Useful for reading at nearby replicas without the distributed
timestamp negotiation overhead of OfMaxStaleness(TimeSpan).
public static TimestampBound OfMaxStaleness(TimeSpan duration)
Read data at a timestamp >= NOW - <code class="paramref">duration</code>. Guarantees that all
writes that have committed more than the specified number of seconds ago are
visible.
Because Cloud Spanner chooses the exact timestamp, this mode works even if
the client's local clock is substantially skewed from Cloud Spanner
commit timestamps.
Useful for reading the freshest data available at a nearby
replica, while bounding the possible staleness if the local
replica has fallen behind.
Note that this option can only be used in single-use
transactions.
public static TimestampBound OfMinReadTimestamp(DateTime minReadTimestamp)
Executes all reads at a timestamp >= minReadTimestamp.
This is useful for requesting fresher data than some previous
read, or data that is fresh enough to observe the effects of some
previously committed transaction whose timestamp is known.
Note that this option can only be used in single-use transactions
public static TimestampBound OfReadTimestamp(DateTime timestamp)
Executes all reads at the given timestamp. Unlike other modes,
reads at a specific timestamp are repeatable; the same read at
the same timestamp always returns the same data. If the
timestamp is in the future, the read will block until the
specified timestamp, modulo the read's deadline.
Useful for large scale consistent reads such as mapreduces, or
for coordinating many reads against a consistent snapshot of the
data.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe latest version of the \u003ccode\u003eTimestampBound\u003c/code\u003e class is 5.0.0-beta05, with several other versions available, ranging from 5.0.0-beta04 down to 3.5.0.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eTimestampBound\u003c/code\u003e is used in Spanner read-only transactions to define the timestamp at which data will be read, with options including strong reads, bounded staleness, and exact staleness.\u003c/p\u003e\n"],["\u003cp\u003eYou can set the \u003ccode\u003eMode\u003c/code\u003e property to determine how the timestamp is chosen, and use \u003ccode\u003eStaleness\u003c/code\u003e to define the duration of staleness if it is not the latest.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eTimestampBound\u003c/code\u003e class supports various methods for creating instances, including reading data at exact staleness, max staleness, or a specified timestamp.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eTimestampBound\u003c/code\u003e class can be serialized to and from a Base64 encoded string using the \u003ccode\u003eToBase64String\u003c/code\u003e and \u003ccode\u003eFromBase64String\u003c/code\u003e methods, respectively, and it is also possible to control whether a read timestamp is returned using \u003ccode\u003eWithReturnReadTimestamp\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Google.Cloud.Spanner.Data - Class TimestampBound (5.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [5.1.0 (latest)](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/5.0.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.6.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.5.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.4.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.3.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.2.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.1.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.0.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.15.1/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.14.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.13.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.12.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.11.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.10.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.9.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.8.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.7.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.6.0/Google.Cloud.Spanner.Data.TimestampBound)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.5.0/Google.Cloud.Spanner.Data.TimestampBound) \n\n public sealed class TimestampBound : IEquatable\u003cTimestampBound\u003e\n\nReference documentation and code samples for the Google.Cloud.Spanner.Data class TimestampBound.\n\nIndicates how Spanner will choose a timestamp at which to read the data for read-only\ntransactions. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e TimestampBound \n\nImplements\n----------\n\n[IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[TimestampBound](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound) \n\nInherited Members\n-----------------\n\n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Spanner.Data](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data)\n\nAssembly\n--------\n\nGoogle.Cloud.Spanner.Data.dll\n\nProperties\n----------\n\n### Mode\n\n public TimestampBoundMode Mode { get; }\n\nIndicates how to choose the timestamp at which to read the data for Cloud Spanner read-only transactions.\nIf your application can tolerate some staleness when reading data, you can use a stale read,\nwhich can execute much faster when compared to reading the latest data.\nThe types of timestamp bounds are:\nStrong (the default): read the latest data.\nBounded staleness: read a version of the data that's no staler than a bound.\nExact staleness: read the version of the data at an exact timestamp.\n\n### ReturnReadTimestamp\n\n public bool ReturnReadTimestamp { get; }\n\nIf true, the read timestamp is included in the\nGoogle.Cloud.Spanner.V1.Transaction message that describes the transaction.\n\n### Staleness\n\n public TimeSpan Staleness { get; }\n\nIf [Mode](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound#Google_Cloud_Spanner_Data_TimestampBound_Mode) is [ExactStaleness](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBoundMode#Google_Cloud_Spanner_Data_TimestampBoundMode_ExactStaleness) or\n[MaxStaleness](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBoundMode#Google_Cloud_Spanner_Data_TimestampBoundMode_MaxStaleness), this indicates the duration of time\nfor the staleness.\n\n### Strong\n\n public static TimestampBound Strong { get; }\n\nRead at a timestamp where all previously committed transactions\nare visible.\n\n### Timestamp\n\n public DateTime Timestamp { get; }\n\nIf [Mode](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound#Google_Cloud_Spanner_Data_TimestampBound_Mode) is [ReadTimestamp](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBoundMode#Google_Cloud_Spanner_Data_TimestampBoundMode_ReadTimestamp) or\n[MinReadTimestamp](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBoundMode#Google_Cloud_Spanner_Data_TimestampBoundMode_MinReadTimestamp), this indicates the timestamp to use.\n\nMethods\n-------\n\n### FromBase64String(string)\n\n public static TimestampBound FromBase64String(string base64String)\n\nCreates an instance of [TimestampBound](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound) given its Base64 encoded string.\n\n### GetHashCode()\n\n public override int GetHashCode()\n\nServes as the default hash function.\n\n**Overrides** \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)\n\n### OfExactStaleness(TimeSpan)\n\n public static TimestampBound OfExactStaleness(TimeSpan duration)\n\nExecutes all reads at a timestamp that is `duration`\nold. The timestamp is chosen soon after the read is started.\n\nGuarantees that all writes that have committed more than the\nspecified number of seconds ago are visible. Because Cloud Spanner\nchooses the exact timestamp, this mode works even if the client's\nlocal clock is substantially skewed from Cloud Spanner commit\ntimestamps.\n\nUseful for reading at nearby replicas without the distributed\ntimestamp negotiation overhead of [OfMaxStaleness(TimeSpan)](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound#Google_Cloud_Spanner_Data_TimestampBound_OfMaxStaleness_System_TimeSpan_).\n\n### OfMaxStaleness(TimeSpan)\n\n public static TimestampBound OfMaxStaleness(TimeSpan duration)\n\nRead data at a timestamp \\\u003e= `NOW - \u003ccode class=\"paramref\"\u003eduration\u003c/code\u003e`. Guarantees that all\nwrites that have committed more than the specified number of seconds ago are\nvisible.\nBecause Cloud Spanner chooses the exact timestamp, this mode works even if\nthe client's local clock is substantially skewed from Cloud Spanner\ncommit timestamps.\n\nUseful for reading the freshest data available at a nearby\nreplica, while bounding the possible staleness if the local\nreplica has fallen behind.\n\nNote that this option can only be used in single-use\ntransactions.\n\n### OfMinReadTimestamp(DateTime)\n\n public static TimestampBound OfMinReadTimestamp(DateTime minReadTimestamp)\n\nExecutes all reads at a timestamp \\\u003e= `minReadTimestamp`.\n\nThis is useful for requesting fresher data than some previous\nread, or data that is fresh enough to observe the effects of some\npreviously committed transaction whose timestamp is known.\n\nNote that this option can only be used in single-use transactions\n\n### OfReadTimestamp(DateTime)\n\n public static TimestampBound OfReadTimestamp(DateTime timestamp)\n\nExecutes all reads at the given timestamp. Unlike other modes,\nreads at a specific timestamp are repeatable; the same read at\nthe same timestamp always returns the same data. If the\ntimestamp is in the future, the read will block until the\nspecified timestamp, modulo the read's deadline.\n\nUseful for large scale consistent reads such as mapreduces, or\nfor coordinating many reads against a consistent snapshot of the\ndata.\n\n### ToBase64String()\n\n public string ToBase64String()\n\nReturns a Base64 encoded string that can later be serialized back into a [TimestampBound](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound)\nusing [FromBase64String(string)](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound#Google_Cloud_Spanner_Data_TimestampBound_FromBase64String_System_String_)\n\n### WithReturnReadTimestamp(bool)\n\n public TimestampBound WithReturnReadTimestamp(bool returnReadTimestamp)\n\nCreates a [TimestampBound](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.TimestampBound) with the given value on\nwhether to return a read timestamp."]]