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

  • Home
  • SEARCH
  • 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 8623957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:24:26+00:00 2026-06-12T07:24:26+00:00

In my older post, I tried to change the date to current date and

  • 0

In my older post, I tried to change the date to current date and add 8 hours time.

SQL Server: convert to today then add 8 hours

UPDATE business.dbo.db_schedule
SET nextUpdate= DATEADD(hh, 8,
                DATEADD(d, DATEDIFF(D,nextUpdate,Getdate()),
                          nextUpdate))
where sno=8

note: nextUpdate may be any time in the past.

if I want to go one step further; I want nextdate to be in the future time.
Because if I add 8 hour once, the result may be still a time in the past, I may have to add one more (or even twice) so the result is in the future. Can i do it in one step?

  • 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-06-12T07:24:27+00:00Added an answer on June 12, 2026 at 7:24 am
    UPDATE business.dbo.db_schedule
    SET nextUpdate =
      DATEADD(HOUR
        , 8 * CEILING((DATEDIFF(MILLISECOND, nextUpdate, GETDATE()) / 3600000.) / 8.)
        , nextUpdate)
      )
    WHERE sno = 8;
    

    Instead of just adding 8 hours, we multiply 8 by the CELING of the number of hours apart nextUpdate is from GETDATE()

    e.g. If nextUpdate is 2012-10-01 02:30:00 and GETDATE() is currently 2012-10-02 15:15:00, then there are 36.75 (rounded up to 37) Hours difference. The CEILING of 37 / 8 is 5, which means you will need to add 5 * 8 hours to get a time that is after GETDATE() yet retains the multiple of 8 hours from your current nextUpdate value.

    SQLFiddle example of the solution

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have followed a link http://lukesampson.com/post/315838839/cas-on-windows-localhost-setup-in-5-mins , then the cas server works correctly, the
Rehashing an older post: JQuery VS Flex - Choosing a Platform for SAAS We
Looking at an older stackoverflow post (back in June 2009, Is the WCF REST
I followed this post http://neurochannels.blogspot.com/2010/05/how-to-run-r-code-in-matlab.html , to install R(D)Com server in order to call
I am using simple_form in my Rails application, I tried to add form-horizontal class
i first tried to make request to server with GET method and it works
I'm trying to write an UPDATE SQL Query to clean up my database a
this is my first time to post a question here, I will try to
I need to dynamically add option choices to the cart items at the time
I tried numerous times over the last few weeks to get a server side

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.