mysql 时间戳与日期格式的相互转换 https://blog.csdn.net/u013372487/article/details/48131589
sqlserver 时间戳--日期 转换 https://blog.csdn.net/sinat_20174131/article/details/78543550
每日一SQL-善用DATEADD和DATEDIFF https://dotblogs.com.tw/lastsecret/2010/10/04/18097
应用例子:
----------------------------------------------------------------------------------------------------
USE QPAccountsDB
GO
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE ID = OBJECT_ID(N'[dbo].[GSP_GR_FindLoginTime]') and OBJECTPROPERTY(ID, N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[GSP_GR_FindLoginTime]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
----------------------------------------------------------------------------------------------------
-- 设置权限
CREATE PROC GSP_GR_FindLoginTime
@dwUserID INT, -- 用户 I D
@RegisterDate INT OUTPUT -- 输出信息
WITH ENCRYPTION AS
-- 属性设置
SET NOCOUNT ON
-- 执行逻辑
BEGIN
--查询登录时间
DECLARE @strTime NVARCHAR(32)
SELECT @strTime=RegisterDate FROM AccountsInfo(NOLOCK) WHERE UserID=@dwUserID
SELECT @RegisterDate = DATEDIFF(S,'1970-01-01 00:00:00', @strTime ) - 8 * 3600
END
RETURN 0
GO
----------------------------------------------------------------------------------------------------