---
product: Chilkat
product_version: 11.7.0
language: sqlserver
language_label: SQL Server
class: CkDateTime
license: free
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/sqlserver_CkDateTimeRef.html
---
# Chilkat CkDateTime — SQL Server — v11.7.0

> Chilkat 11.7.0 · language=sqlserver · class=CkDateTime
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/CkDateTime.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/sqlserver/guide.md`.

## Purpose

`CkDateTime` represents a date/time value and provides conversion methods for common date/time formats, including .NET DateTime, DateTime ticks, RFC 822, RFC 3339 / ISO 8601-style timestamps, Unix time, DOS date/time, OLE DATE, NTP time, ULID timestamps, and Chilkat DtObj. It also supports date arithmetic, age/expiration checks, serialization, and local/UTC conversion.

For an extended overview, see [CkDateTime Class Overview](https://www.chilkatsoft.com/ckdatetime_class_overview.asp)

## Object creation, unlocking and error handling

**Object Creation**

```sql
DECLARE @hr int
DECLARE @ckDateTime int
EXEC @hr = sp_OACreate 'Chilkat.CkDateTime', @ckDateTime OUT
IF @hr <> 0
BEGIN
    PRINT 'Failed to create ActiveX component'
    RETURN
END

-- ... use @ckDateTime ...

EXEC @hr = sp_OADestroy @ckDateTime
```

T-SQL uses the Chilkat ActiveX through the OLE Automation stored procedures. They must be enabled once on the server (`EXEC sp_configure 'Ole Automation Procedures', 1; RECONFIGURE;`), and the Chilkat ActiveX registered must match the bitness of the SQL Server instance (64-bit for a 64-bit SQL Server). To bind to a specific major version of Chilkat, append the major version number to the ProgID, such as `sp_OACreate 'Chilkat.CkDateTime.11'` for Chilkat v11.\*.\*.

`sp_OACreate` returns an object token (an `int`) that is passed as the first argument of every `sp_OAMethod`, `sp_OAGetProperty` and `sp_OASetProperty` call, and released with `sp_OADestroy`. Objects returned by methods (such as an `HttpResponse` or `JsonObject`) are also tokens received through an `int` OUT parameter; they must likewise be destroyed, and the OUT parameter is `NULL` when the method fails to return an object. Objects passed as arguments are passed by their token. When an OLE Automation procedure itself fails (non-zero `@hr`), `sp_OAGetErrorInfo` describes the error.

Data types: strings are `nvarchar(4000)`; integers, booleans (1 or 0) and object tokens are `int`; dates are `datetime`. In the signatures on this page, `@success`, `@iResult`, `@sResult` and the like are the OUT variables receiving a method's return value, `@iValue` / `@sValue` receive or supply a property value, and the remaining `@` variables are the method's arguments in order.

A string returned through an OUT parameter is limited to 4000 characters. For longer values, retrieve the result as a result set into a table variable instead of an OUT parameter, for example `DECLARE @tmp TABLE (outputLine ntext)` followed by `INSERT INTO @tmp EXEC sp_OAGetProperty @ckDateTime, 'LastErrorText'`. See [string length limitations for strings returned by sp_OAMethod calls](https://www.chilkatsoft.com/sql_server_nvarchar_max_limitation.asp).

Methods that pass or return raw byte arrays are not shown on this page, because `varbinary(max)` values cannot be exchanged through `sp_OAMethod` (see [varbinary(max) limitation](https://www.chilkatsoft.com/sql_server_varbinary_max_limitation.asp)). Use the `BinData`-based alternatives (methods ending in *Bd*) or the base64 / hex string-encoded variants instead. Binary *properties* (such as `LastBinaryResult`) can be retrieved as a result set into a table variable, as shown in their signatures. Asynchronous (*\*Async*) methods and event callbacks are not available from SQL Server.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in SQL Server.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `EXEC sp_OAGetProperty @ckDateTime, 'DebugLogFilePath', @sValue OUT EXEC sp_OASetProperty @ckDateTime, 'DebugLogFilePath', @sValue` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastBinaryResult` | `INSERT INTO @tmp EXEC sp_OAGetProperty @ckDateTime, 'LastBinaryResult'` | read-only | This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. |
| `LastErrorHtml` | `EXEC sp_OAGetProperty @ckDateTime, 'LastErrorHtml', @sValue OUT` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `EXEC sp_OAGetProperty @ckDateTime, 'LastErrorText', @sValue OUT` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `EXEC sp_OAGetProperty @ckDateTime, 'LastErrorXml', @sValue OUT` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `EXEC sp_OAGetProperty @ckDateTime, 'LastMethodSuccess', @iValue OUT EXEC sp_OASetProperty @ckDateTime, 'LastMethodSuccess', @iValue` | read/write | Indicates the success or failure of the most recent method call: `1` means success, `0` means failure. |
| `LastStringResult` | `EXEC sp_OAGetProperty @ckDateTime, 'LastStringResult', @sValue OUT` | read-only | In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. |
| `LastStringResultLen` | `EXEC sp_OAGetProperty @ckDateTime, 'LastStringResultLen', @iValue OUT` | read-only | The length, in characters, of the string contained in the LastStringResult property. |
| `VerboseLogging` | `EXEC sp_OAGetProperty @ckDateTime, 'VerboseLogging', @iValue OUT EXEC sp_OASetProperty @ckDateTime, 'VerboseLogging', @iValue` | read/write | If set to `1`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `EXEC sp_OAGetProperty @ckDateTime, 'Version', @sValue OUT` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `IsDst` | property, read-only | `EXEC sp_OAGetProperty @ckDateTime, 'IsDst', @iValue OUT` |
| `UtcOffset` | property, read-only | `EXEC sp_OAGetProperty @ckDateTime, 'UtcOffset', @iValue OUT` |
| `AddDays` | method | `EXEC sp_OAMethod @ckDateTime, 'AddDays', @success OUT, @numDays` |
| `AddSeconds` | method | `EXEC sp_OAMethod @ckDateTime, 'AddSeconds', @success OUT, @numSeconds` |
| `DeSerialize` | method | `EXEC sp_OAMethod @ckDateTime, 'DeSerialize', NULL, @serializedDateTime` |
| `DiffSeconds` | method | `EXEC sp_OAMethod @ckDateTime, 'DiffSeconds', @iResult OUT, @dateTimeArg` |
| `ExpiresWithin` | method | `EXEC sp_OAMethod @ckDateTime, 'ExpiresWithin', @success OUT, @n, @units` |
| `GetAsDateTime` | method | `EXEC sp_OAMethod @ckDateTime, 'GetAsDateTime', @dtResult OUT, @bLocal` |
| `GetAsDosDate` | method | `EXEC sp_OAMethod @ckDateTime, 'GetAsDosDate', @iResult OUT, @bLocal` |
| `GetAsIso8601` | method | `EXEC sp_OAMethod @ckDateTime, 'GetAsIso8601', @sResult OUT, @formatStr, @bLocal` |
| `GetAsOleDate` | method | `EXEC sp_OAMethod @ckDateTime, 'GetAsOleDate', @fResult OUT, @bLocal` |
| `GetAsRfc822` | method | `EXEC sp_OAMethod @ckDateTime, 'GetAsRfc822', @sResult OUT, @bLocal` |
| `GetAsTimestamp` | method | `EXEC sp_OAMethod @ckDateTime, 'GetAsTimestamp', @sResult OUT, @bLocal` |
| `GetAsUnixTime` | method | `EXEC sp_OAMethod @ckDateTime, 'GetAsUnixTime', @iResult OUT, @bLocal` |
| `GetAsUnixTimeStr` | method | `EXEC sp_OAMethod @ckDateTime, 'GetAsUnixTimeStr', @sResult OUT, @bLocal` |
| `OlderThan` | method | `EXEC sp_OAMethod @ckDateTime, 'OlderThan', @success OUT, @n, @units` |
| `Serialize` | method | `EXEC sp_OAMethod @ckDateTime, 'Serialize', @sResult OUT` |
| `SetFromCurrentSystemTime` | method | `EXEC sp_OAMethod @ckDateTime, 'SetFromCurrentSystemTime', @success OUT` |
| `SetFromDosDate` | method | `EXEC sp_OAMethod @ckDateTime, 'SetFromDosDate', @success OUT, @bLocal, @t` |
| `SetFromDtObj` | method | `EXEC sp_OAMethod @ckDateTime, 'SetFromDtObj', @success OUT, @dt` |
| `SetFromNtpServer` | method | `EXEC sp_OAMethod @ckDateTime, 'SetFromNtpServer', @success OUT, @jsonStr` |
| `SetFromNtpTime` | method | `EXEC sp_OAMethod @ckDateTime, 'SetFromNtpTime', @success OUT, @ntpSeconds` |
| `SetFromOleDate` | method | `EXEC sp_OAMethod @ckDateTime, 'SetFromOleDate', @success OUT, @bLocal, @dt` |
| `SetFromRfc822` | method | `EXEC sp_OAMethod @ckDateTime, 'SetFromRfc822', @success OUT, @rfc822Str` |
| `SetFromTimestamp` | method | `EXEC sp_OAMethod @ckDateTime, 'SetFromTimestamp', @success OUT, @timestamp` |
| `SetFromUlid` | method | `EXEC sp_OAMethod @ckDateTime, 'SetFromUlid', @success OUT, @bLocal, @ulid` |
| `SetFromUnixTime` | method | `EXEC sp_OAMethod @ckDateTime, 'SetFromUnixTime', @success OUT, @bLocal, @t` |
| `ToDtObj` | method | `EXEC sp_OAMethod @ckDateTime, 'ToDtObj', NULL, @bLocal, @dtObj` |
| `UlidGenerate` | method | `EXEC sp_OAMethod @ckDateTime, 'UlidGenerate', @sResult OUT, @bLocal` |
| `UlidIncrement` | method | `EXEC sp_OAMethod @ckDateTime, 'UlidIncrement', @success OUT, @ulid` |
| `UlidValidate` | method | `EXEC sp_OAMethod @ckDateTime, 'UlidValidate', @success OUT, @ulid` |

Deprecated members are listed at the end of this file with their replacements; do not use them in new code.

## Properties

### CkDateTime.IsDst

`Chilkat 11.7.0 · sqlserver · CkDateTime · IsDst · property · read-only`

```sql
EXEC sp_OAGetProperty @ckDateTime, 'IsDst', @iValue OUT
```

This is the Daylight Saving Time flag. It can have one of three possible values: 1, 0, or -1. It has the value 1 if Daylight Saving Time is in effect, 0 if Daylight Saving Time is not in effect, and -1 if the information is not available.

Note: This is NOT the DST for the current system time. It is the DST that was in effect at the date value contained in this object.

### CkDateTime.UtcOffset

`Chilkat 11.7.0 · sqlserver · CkDateTime · UtcOffset · property · read-only`

```sql
EXEC sp_OAGetProperty @ckDateTime, 'UtcOffset', @iValue OUT
```

For the current system's timezone, returns the number of seconds offset from UTC for this date/time. The offset includes daylight savings adjustment. Local timezones west of UTC return a negative offset.

## Methods

### CkDateTime.AddDays

`Chilkat 11.7.0 · sqlserver · CkDateTime · AddDays · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'AddDays', @success OUT, @numDays
```

Adds an integer number of days to the date/time. To subtract days, pass a negative integer.

Returns 1 for success, 0 for failure.

### CkDateTime.AddSeconds

`Chilkat 11.7.0 · sqlserver · CkDateTime · AddSeconds · method · since 9.5.0.65`

```sql
EXEC sp_OAMethod @ckDateTime, 'AddSeconds', @success OUT, @numSeconds
```

Adds an integer number of seconds to the date/time. To subtract seconds, pass a negative integer.

Returns 1 for success, 0 for failure.

### CkDateTime.DeSerialize

`Chilkat 11.7.0 · sqlserver · CkDateTime · DeSerialize · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'DeSerialize', NULL, @serializedDateTime
```

Loads the date/time with a string having the format as produced by the Serialize method, which is a string of SPACE separated integers containing (in this order) year, month, day, hour, minutes, seconds, and a UTC flag having the value of 1/0.

### CkDateTime.DiffSeconds

`Chilkat 11.7.0 · sqlserver · CkDateTime · DiffSeconds · method · since 9.5.0.65`

```sql
EXEC sp_OAMethod @ckDateTime, 'DiffSeconds', @iResult OUT, @dateTimeArg
```

Returns the difference in seconds between the `dateTimeArg` and this date/time. The value returned is this object's date/time - `dateTimeArg`'s date/time. For example, if the returned value is positive, then this object's date/time is more recent than `dateTimeArg`'s date/time. If the return value is negative, then this object's date/time is older than `dateTimeArg`'s date/time.

### CkDateTime.ExpiresWithin

`Chilkat 11.7.0 · sqlserver · CkDateTime · ExpiresWithin · method · since 9.5.0.67`

```sql
EXEC sp_OAMethod @ckDateTime, 'ExpiresWithin', @success OUT, @n, @units
```

Returns `1` if the date/time is within `n` seconds/minutes/hours/days of the current system date/time. Otherwise returns `0`. The `units` can be `seconds`, `minutes`, `hours`, or `days` (plural or singular).

### CkDateTime.GetAsDateTime

`Chilkat 11.7.0 · sqlserver · CkDateTime · GetAsDateTime · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'GetAsDateTime', @dtResult OUT, @bLocal
```

Returns the date/time in a native format. The .NET implementation returns a .NET System.DateTime structure. The ActiveX implementation returns a Date object.

`bLocal` indicates whether a local or UTC time is returned.

### CkDateTime.GetAsDosDate

`Chilkat 11.7.0 · sqlserver · CkDateTime · GetAsDosDate · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'GetAsDosDate', @iResult OUT, @bLocal
```

Returns the date/time as a 32-bit DOS date/time bitmask.

`bLocal` indicates whether a local or UTC time is returned.

The DOS date/time format is a bitmask:

```

			   24                16                 8                 0
	    +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
	    |Y|Y|Y|Y|Y|Y|Y|M| |M|M|M|D|D|D|D|D| |h|h|h|h|h|m|m|m| |m|m|m|s|s|s|s|s|
	    +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
	     \___________/\________/\_________/ \________/\____________/\_________/
		 year        month       day      hour       minute        second
```

The year is stored as an offset from 1980. Seconds are stored in two-second increments. (So if the `second` value is 15, it actually represents 30 seconds.)

### CkDateTime.GetAsIso8601

`Chilkat 11.7.0 · sqlserver · CkDateTime · GetAsIso8601 · method · since 9.5.0.65`

```sql
EXEC sp_OAMethod @ckDateTime, 'GetAsIso8601', @sResult OUT, @formatStr, @bLocal
```

Returns the date/time in a compatible ISO 8601 format according to the format specified in `formatStr`.. Examples of ISO 8601 formats include the following:

```
    YYYY-MM-DD

    YYYY-MM-DDThh:mmTZD

    YYYY-MM-DDThh:mm:ssTZD

    YYYY-MM-DDThh:mm:ss:sssTZD
```

For the date portion of these formats, `YYYY` is a four-digit year representation, `MM` is a two-digit month, and `DD` is a two-digit day. For the time portion, `hh` is the hour in 24-hour notation, `mm` is the two-digit minutes, `ss` is the two-digit seconds, and `sss` is the 3-digit milliseconds. A time designator `T` separates the date and time portions of the string, while a time zone designator `TZD` specifies a time zone (UTC).

`bLocal` indicates whether a local or UTC time is returned.

Returns `NULL` on failure

### CkDateTime.GetAsOleDate

`Chilkat 11.7.0 · sqlserver · CkDateTime · GetAsOleDate · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'GetAsOleDate', @fResult OUT, @bLocal
```

Returns the date/time in a Windows OLE `DATE` format.

`bLocal` indicates whether a local or UTC time is returned.

The OLE automation date format is a floating point value, counting days since midnight 30 December 1899. Hours and minutes are represented as fractional days.

### CkDateTime.GetAsRfc822

`Chilkat 11.7.0 · sqlserver · CkDateTime · GetAsRfc822 · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'GetAsRfc822', @sResult OUT, @bLocal
```

Returns the date/time as an RFC822 formatted string. (An RFC822 format string is what is found in the `Date` header field of an email, such as `Wed, 18 Oct 2017 09:08:21 GMT`.)

`bLocal` indicates whether a local or UTC time is returned.

Returns `NULL` on failure

### CkDateTime.GetAsTimestamp

`Chilkat 11.7.0 · sqlserver · CkDateTime · GetAsTimestamp · method · since 9.5.0.58`

```sql
EXEC sp_OAMethod @ckDateTime, 'GetAsTimestamp', @sResult OUT, @bLocal
```

Returns the date/time as an RFC 3339 formatted string, such as `1990-12-31T23:59:60Z`. (This is an ISO 8061 format like the following: YYYY-MM-DDThh:mm:ssTZD)

`bLocal` indicates whether a local or UTC time is returned.

Returns `NULL` on failure

### CkDateTime.GetAsUnixTime

`Chilkat 11.7.0 · sqlserver · CkDateTime · GetAsUnixTime · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'GetAsUnixTime', @iResult OUT, @bLocal
```

Returns the date/time as a Unix time value, which is the number of seconds elapsed since 00:00:00 UTC on January 1, 1970.

`bLocal` indicates whether the date/time returned is local or UTC.

### CkDateTime.GetAsUnixTimeStr

`Chilkat 11.7.0 · sqlserver · CkDateTime · GetAsUnixTimeStr · method · since 9.5.0.65`

```sql
EXEC sp_OAMethod @ckDateTime, 'GetAsUnixTimeStr', @sResult OUT, @bLocal
```

Returns the time in Unix format (in seconds since the epoch: 00:00:00 UTC on 1 January 1970).

`bLocal` indicates whether the date/time returned is local or UTC.

Returns `NULL` on failure

### CkDateTime.OlderThan

`Chilkat 11.7.0 · sqlserver · CkDateTime · OlderThan · method · since 9.5.0.67`

```sql
EXEC sp_OAMethod @ckDateTime, 'OlderThan', @success OUT, @n, @units
```

Returns `1` if the date/time is older than the current system date/time by `n` seconds/minutes/hours/days. Otherwise returns `0`. The `units` can be `seconds`, `minutes`, `hours`, or `days` (plural or singular).

### CkDateTime.Serialize

`Chilkat 11.7.0 · sqlserver · CkDateTime · Serialize · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'Serialize', @sResult OUT
```

Serializes the date/time to a us-ascii string that can be imported at a later time via the DeSerialize method. The format of the string returned by this method is not intended to match any published standard. It is formatted to a string with SPACE separated integers containing (in this order) year, month, day, hour, minutes, seconds, and a UTC flag having the value of 1 or 0.

Returns `NULL` on failure

### CkDateTime.SetFromCurrentSystemTime

`Chilkat 11.7.0 · sqlserver · CkDateTime · SetFromCurrentSystemTime · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'SetFromCurrentSystemTime', @success OUT
```

Sets the date/time from the current system time.

Returns 1 for success, 0 for failure.

### CkDateTime.SetFromDosDate

`Chilkat 11.7.0 · sqlserver · CkDateTime · SetFromDosDate · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'SetFromDosDate', @success OUT, @bLocal, @t
```

Sets the date/time from a 32-bit DOS date/time bitmask. See GetAsDosDate for more information.

Returns 1 for success, 0 for failure.

### CkDateTime.SetFromDtObj

`Chilkat 11.7.0 · sqlserver · CkDateTime · SetFromDtObj · method · since 9.5.0.47`

```sql
EXEC sp_OAMethod @ckDateTime, 'SetFromDtObj', @success OUT, @dt
```

Sets the date/time from a Chilkat `Dt` object.

Returns 1 for success, 0 for failure.

### CkDateTime.SetFromNtpServer

`Chilkat 11.7.0 · sqlserver · CkDateTime · SetFromNtpServer · method · since 9.5.0.96`

```sql
EXEC sp_OAMethod @ckDateTime, 'SetFromNtpServer', @success OUT, @jsonStr
```

Sets the date/time by sending a query to an NTP server.

Returns 1 for success, 0 for failure.

### CkDateTime.SetFromNtpTime

`Chilkat 11.7.0 · sqlserver · CkDateTime · SetFromNtpTime · method · since 9.5.0.50`

```sql
EXEC sp_OAMethod @ckDateTime, 'SetFromNtpTime', @success OUT, @ntpSeconds
```

Sets the date/time from a 32-bit NTP time value. `ntpSeconds` is the number of seconds since 00:00 (midnight) 1 January 1900 GMT.

Returns 1 for success, 0 for failure.

### CkDateTime.SetFromOleDate

`Chilkat 11.7.0 · sqlserver · CkDateTime · SetFromOleDate · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'SetFromOleDate', @success OUT, @bLocal, @dt
```

Sets the date/time from a Windows OLE `DATE` value.

`bLocal` indicates whether the passed in date/time is local or UTC.

**Note:** This method was not working correctly. The problem was discovered just after releasing v9.5.0.65. It will be fixed in the next version update.

Returns 1 for success, 0 for failure.

### CkDateTime.SetFromRfc822

`Chilkat 11.7.0 · sqlserver · CkDateTime · SetFromRfc822 · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'SetFromRfc822', @success OUT, @rfc822Str
```

Sets the date/time from an RFC822 date/time formatted string. Here are some examples of RFC822 formatted date/times:

```
Tue, 15 Nov 2022 22:00:58 +0000
Tue, 15 Nov 2022 20:21:50 +0100
Tue, 01 Nov 2022 18:09:41 -0600
```

Returns 1 for success, 0 for failure.

### CkDateTime.SetFromTimestamp

`Chilkat 11.7.0 · sqlserver · CkDateTime · SetFromTimestamp · method · since 9.5.0.58`

```sql
EXEC sp_OAMethod @ckDateTime, 'SetFromTimestamp', @success OUT, @timestamp
```

Sets the date/time from an RFC 3339 timestamp format. (such as `1990-12-31T23:59:60Z:`)

(This is an ISO 8061 format like the following: YYYY-MM-DDThh:mm:ssTZD)

**Note:** Starting in v9.5.0.77, strings formatted as `YYMMDDhhmmssZ`, such as `181221132225Z`, can also be passed to this method.

Returns 1 for success, 0 for failure.

### CkDateTime.SetFromUlid

`Chilkat 11.7.0 · sqlserver · CkDateTime · SetFromUlid · method · since 9.5.0.94`

```sql
EXEC sp_OAMethod @ckDateTime, 'SetFromUlid', @success OUT, @bLocal, @ulid
```

Sets this object's date/time using the timestamp embedded in the `ulid`. If the `ulid` was not a valid ULID, returns `0` and the date/time is not set. `bLocal` indicates whether the `ulid` uses a local time or UTC time.

Returns 1 for success, 0 for failure.

### CkDateTime.SetFromUnixTime

`Chilkat 11.7.0 · sqlserver · CkDateTime · SetFromUnixTime · method`

```sql
EXEC sp_OAMethod @ckDateTime, 'SetFromUnixTime', @success OUT, @bLocal, @t
```

Sets the date/time from a UNIX time value.

`bLocal` indicates whether the passed in date/time is local or UTC.

Returns 1 for success, 0 for failure.

### CkDateTime.ToDtObj

`Chilkat 11.7.0 · sqlserver · CkDateTime · ToDtObj · method · since 11.0.0`

```sql
EXEC sp_OAMethod @ckDateTime, 'ToDtObj', NULL, @bLocal, @dtObj
```

Copies the date/time to the `dtObj`. Gets the date/time in the local time if `bLocal` is `1`, or GMT if `bLocal` is `0`.

### CkDateTime.UlidGenerate

`Chilkat 11.7.0 · sqlserver · CkDateTime · UlidGenerate · method · since 9.5.0.94`

```sql
EXEC sp_OAMethod @ckDateTime, 'UlidGenerate', @sResult OUT, @bLocal
```

Generates and returns a new ULID using this object's date/time value. `bLocal` indicates whether to use local time or UTC time.

Returns `NULL` on failure

### CkDateTime.UlidIncrement

`Chilkat 11.7.0 · sqlserver · CkDateTime · UlidIncrement · method · since 9.5.0.94`

```sql
EXEC sp_OAMethod @ckDateTime, 'UlidIncrement', @success OUT, @ulid
```

Increments the ULID that is passed in `ulid`.

Returns 1 for success, 0 for failure.

### CkDateTime.UlidValidate

`Chilkat 11.7.0 · sqlserver · CkDateTime · UlidValidate · method · since 9.5.0.94`

```sql
EXEC sp_OAMethod @ckDateTime, 'UlidValidate', @success OUT, @ulid
```

Validates the `ulid`. Returns `1` if the `ulid` is valid, otherwise returns `0`.

Returns 1 for success, 0 for failure.

## Deprecated members — do not use in new code

| Member | Kind | Deprecated in | Use instead |
|---|---|---|---|
| `GetDtObj` | method | before 11.6.1 | — |

## Related classes

[`DtObj`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/sqlserver/classes/DtObj.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/sqlserver/classes/StringBuilder.md)

