请问datatime和bigint转换的算法是什么?你要怎么换呢?select CONVERT(varchar(10), getDate(),120) --不要时间2002-1-1
select convert(char(8),getdate(),112) ----20020101
select convert(char(8),getdate(),108)  ---06:05:05select year(getdate()) --年
select month(getdate()) --月
select day(getdate()) --日select  dateadd(month,-24,'2002-12-14')
---------------------^^^减
select  dateadd(day,-24,'2002-12-14')
----------------^^^天或year年select datediff(day,'2001-1-1','2002-1-1') 天
select datediff(month'2001-1-1','2002-1-1') 月
select datediff(year,'2001-1-1','2002-1-1') 年select datename(weekday,getdate())  ---星期

解决方案 »

  1.   

    SQL Server timestamp 数据类型与时间和日期无关。SQL Server timestamp 是二进制数字,它表明数据库中数据修改发生的相对顺序。实现 timestamp 数据类型最初是为了支持 SQL Server 恢复算法。每次修改页时,都会使用当前的 @@DBTS 值对其做一次标记,然后 @@DBTS 加1。这样做足以帮助恢复过程确定页修改的相对次序,但是 timestamp 值与时间没有任何关系。在 SQL Server 7.0 版和 SQL Server 2000 中,@@DBTS 只在 timestamp 列中使用时其值才会递增。如果一个表包含 timestamp 列,则每次由 INSERT、UPDATE 或DELETE 语句修改一行时,此行的 timestamp 值就被置为当前的 @@DBTS 值,然后 @@DBTS 加1。因为每一次修改时 timestamp 值都会改变,所以千万不要在键(特别是主键)中使用 timestamp 列。若要记录表中发生的数据修改次数,可用 datetime 或 smalldatetime 数据类型来记录这些事件和触发器,这样,当发生修改时,就可以自动更新其值。
      

  2.   

    注意:SQL Server timestamp 数据类型与时间和日期无关
      

  3.   

    stampcolumn 不是已定义的系统类型,不能使用CONVERT和CAST
      

  4.   

    大家好像不知道我在文什么?试试这两句
    select convert(datetime, 0x00000000009A4345)
    select convert(datetime, 0x00000000019A4345)
      

  5.   

    怎么会不能转换?
    datetime能表示的时间是从:1753-1-1 至 9999-12-31
    下面的转换均成功啊?declare @d datetime,@i bigint
    set @d='9999-12-31'
    select @i=convert(bigint,@d)
    select @iset @d='1753-1-1'
    select @i=convert(bigint,@d)
    select @i
      

  6.   

    datetime精确到毫秒啊,你这么试就能说明问题吗?能试试精确的时间吗?
      

  7.   

    我的体会
    declare @d datetime,@i bigint
    set @d='9999-12-31'
    select @i=convert(bigint,@d)
    select @iset @d='9999-12-31 00:00:00.001'
    select @i=convert(bigint,@d)
    select @iset @d='1753-1-1'
    select @i=convert(bigint,@d)
    select @iselect convert(datetime,-53690)
    select convert(datetime,2958463)
    select convert(datetime,2958464)select convert(datetime,0x0)
    select convert(datetime,0x18B8199)
    select convert(datetime,0x18B8200)