将时间转换成数字,把数字转换成时间,均匀取一定时间间隔(比如每91秒取一条记录)内的符合条件的记录
/****** Script for SelectTopNRows command from SSMS ******/
SELECT [id]
,[tagDate],CAST(tagdate as float)*10000000000 as numdate
,[HZ105_315HH]
,[HZ105_DO315AI]
,[HZ105_FI315AI]
,[HZ105_PH315AI]
,[HZ105_PI315AI]
,[HZ105_TI315AI]
,[HZ105_WI315AI]
,[HZ105_ZS315AI]
FROM [IhHisdata].[dbo].[dat_hisdata]
where CAST( CAST(tagdate as float)*10000000000 as decimal)%91=0 --10000000000是为了将浮点转换成整数,便于取模
将时间转换成数字,把数字转换成时间
select GETDATE() as t, CAST('2014-11-15 15:44:08.470' as datetime) as tt, CAST(41956.655653588 as datetime)