DateName(类型,时间)%5=0

类型:

日期部分 缩写

year  

yy, yyyy

quarter 

qq, q

month

mm, m

dayofyear

dy, y

day

dd, d

week

wk, ww

weekday

dw

hour

hh

minute

mi, n

second

ss, s

millisecond

ms

 时间:就是字段为日期时间的字段。

 

举例:取一天当中,间隔为5分钟的的记录

 

declare @flag varchar(32) set @flag='c115:'
select   SampleTime ,  
replace ( substring ( SampleValues , charindex ( ''+@flag+'' , SampleValues ) , charindex ( ',', substring ( SampleValues , charindex ( ''+@flag+'' , SampleValues ) , len ( SampleValues ) ) ) - 1 ) ,''+@flag+'' , '')   
as YcValue  
from [SHDQ_MGM1000_TEST].[dbo].[TYcHistory_201707]    
where charindex (''+@flag+'' , SampleValues ) > 0   
and  DateName(minute,SampleTime)%5=0  
and  datediff(day,SampleTime,'2017/7/06 0:00:00')=0 

 

相关文章:

  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
相关资源
相似解决方案