Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

DatePart To Select Data at Half Hour Mark

Explorer ,
Mar 10, 2009 Mar 10, 2009
I have a view in SQL server I am selecting from. I am getting a bunch of timestamped logs. I only want to select the logs at the half hour mark 1:00, 1:30, 2:00, 2:30 etc. The following code works fine:

select PointName, [DateTime], PointValue From dbo.ExtendedLog_view

where PointName IN ('R481A_Litestatus', 'R481_Litestatus','R481A_SpaceHum', 'R481_SpaceHum','R481ASpace' ,'R481Space') and [DateTime] > #DateAdd('h',-12, todayDate)# and DatePart("n", [DateTime]) = '00'

I get all the logs timestamped with a minute of 00. If I add another DatePart factor the page processes and just gets stuck there. Adding an additional "or DatePart("n", [DateTime]) = '30'" seems to lock the page up.

Any ideas as to why this might be happening? Is there any other method I can use to only select logs timestamped on the hafl hour mark?
655
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 10, 2009 Mar 10, 2009
LATEST
NM I ended up figuring it out. I needed parentheses around the whole or statement.

(DatePart("n", [DateTime]) = '00' or DatePart("n", [DateTime]) = '30' )
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources