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 8483189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:01:29+00:00 2026-06-10T20:01:29+00:00

I am trying to update my SQL DB when the the date has expired

  • 0

I am trying to update my SQL DB when the the date has expired (i.e is less than now)
I have this lovely bit of SQL code

Update Notifications 
SET Active = 'N' 
where CAST(SetDate AS DATE) <= CAST('2012-08-23 11:19:00 +0000' AS DATE)

But it updates all the records (even if the date is not less than now)

I have also tried

Update Notifications 
SET Active = 'N' 
where CAST(SetDate AS DATE) < CAST('2012-08-23 11:19:00 +0000' AS DATE)

But this dosent affect any rows.

I guess I have something a little confused??

Any help???

Thanks

  • 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-10T20:01:30+00:00Added an answer on June 10, 2026 at 8:01 pm

    I cannot see anything odd about the code, except for this line:

    CAST('2012-08-23 11:19:00 +0000' AS DATE)
    

    If you are using CAST() to change it to the date, then there is no need to pass in the time portion of the value.

    You did not provide the full table schema but one thing to consider is using a bit field for the Y/N values.

    Here is a SQL Fiddle with the code working

    Update Notifications 
    SET Active = 'N' 
    where CAST(SetDate AS DATE) <= CAST('2012-08-23' AS DATE)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to use sql NOW() function while I update a table.
I have the following SQL statement where i'm trying to update multiple rows matching
I'm trying to flip a bit field in SQL Server using an update query,
I have this C# webform that has has a date picker box. If the
I'm trying to update an NText field in SQL 2000 using Classic ASP. Here
So I'm trying to update an object in my MS SQL 2005 database using
I am trying to figure out how I can update my sql query dynamically.
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; What I'm ultimately trying to do is update a sql
I am trying to use an update trigger in SQL Server 2000 so that
I'm trying to create an SQL query in PHP to update a table. Is

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.