Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6185817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:46:51+00:00 2026-05-24T01:46:51+00:00

I am attempting to query my table which has the schema: CREATE TABLE [dbo].[FIN_MeetingDisplay-DefaultConfig](

  • 0

I am attempting to query my table which has the schema:

  CREATE TABLE [dbo].[FIN_MeetingDisplay-DefaultConfig](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [name] [varchar](150) NOT NULL,
    [value] [nvarchar](max) NOT NULL
  )

Two values in the table store a time when Power Saving should be enabled or disabled:

EnablePowerSave 10:00PM
DisablePowerSave 08:00AM

What I am wanting to do is query the table to see if the current time is between the EnablePowerSave and DisablePowerSave window.

I am currently querying it with the following, which is always returning false which is because it is using today’s date. What would be the best way to change the query so that if it is after 8am to use tomorrow’s date and before 8am to use today’s date?

SELECT  CONVERT(DATETIME, CAST(GETDATE() AS VARCHAR(11)) + ' ' + VALUE, 103)
FROM    dbo.[FIN_MeetingDisplay-DefaultConfig]
WHERE   name = 'EnablePowerSave'

Thanks,

Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:46:52+00:00Added an answer on May 24, 2026 at 1:46 am

    This implies some assumed knowledge – that Enable time is on day one and Disable time is always the following day, and you are always running the query on the following day.

    DECLARE @t SMALLDATETIME;
    SET @t = CURRENT_TIMESTAMP;
    
    ;WITH x(n,t) AS
    (
      SELECT name = LEFT(name, 1), 
        DATEADD(DAY, CASE WHEN LEFT(name, 1) = 'E' THEN -1 ELSE 0 END, 
        CONVERT(SMALLDATETIME, CONVERT(CHAR(8), CURRENT_TIMESTAMP, 112) 
        + ' ' + value))
      FROM dbo.[FIN_MeetingDisplay-DefaultConfig]
      WHERE name IN ('EnablePowerSave', 'DisablePowerSave')
    )
    SELECT 
      [start]   = x.t,
      [end]     = y.t,
      [current] = @t,
      [status]  = CASE 
        WHEN @t BETWEEN x.t AND y.t 
            THEN 'between' 
            ELSE 'not between' 
        END
    FROM x 
    CROSS JOIN x AS y
    WHERE x.n = 'E'
    AND y.n = 'D';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to use the DataSet designer to create a datatable from a query.
So I'm attempting to do a query on a table that holds two foreign
I have a LINQ query which is attempting to get all of the distinct
I'm attempting to write a linq query which uses several tables of related data
I'm attempting to delete all rows in one table that do not have a
I have the following Entity: @Entity @Table @NamedQuery(name = Constants.FINDALLFINDERNAME, query = Constants.FINDALLQUERY) public
I'm attempting to write a query that will return any customer that has multiple
I'm attempting to display a table of data which looks like this on Windows
I have a query which attempts to insert a row into a table. It
What I'm attempting to do find values in a table which are less than

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.