Sample code for 30+ languages & platforms
SQL Server

DateTime - Get as Unix Time String

Demonstrates the GetAsUnixTimeStr method.

Note: This example is only valid in Chilkat v9.5.0.65 or later.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @dateTime int
    EXEC @hr = sp_OACreate 'Chilkat.CkDateTime', @dateTime OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int
    EXEC sp_OAMethod @dateTime, 'SetFromCurrentSystemTime', @success OUT

    --  (in seconds since the epoch: 00:00:00 UTC on 1 January 1970)
    DECLARE @bLocal int
    SELECT @bLocal = 1

    EXEC sp_OAMethod @dateTime, 'GetAsUnixTimeStr', @sTmp0 OUT, @bLocal
    PRINT 'Unix time: ' + @sTmp0

    --  Sample output for test run on 2-Dec-2016: 

    --      Unix time: 1480661608

    EXEC @hr = sp_OADestroy @dateTime


END
GO