Solved

SQL:  Conditional Update

Posted on 2014-02-06
4
225 Views
Last Modified: 2014-02-11
Attached is a screenshot of a database table called FRACK.

I'm looking for help creating a SQL update statement which would compare timestamps in columns RACKED and CHILLROOMSCAN.  If the CHILLROOMSCAN is an earlier date than the RACKED date, I would like to increment the CHILLROOMSCAN value by 1 day, leaving the hour/min/sec AM/PM details unchanged.  

If the CHILLROOMSCAN value is the same date or later than the RACKED value, then no change should take place.

Can someone help?
frack.jpg
0
Comment
Question by:mrherndon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 250 total points
ID: 39840192
update frack set chillroomscan = dateadd(dd,1,chillroomscan)
where chillroomscan < racked
0
 

Author Comment

by:mrherndon
ID: 39840360
I see where you're going, but the script error returns column not found:  dd.  Any suggestions?
0
 
LVL 41

Expert Comment

by:Sharath
ID: 39840591
dd is not a column and it is to increment by day. Are you working in MS SQL or MYSQL?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 39841279
in ms sql server, it would by DAY and not DD:
update frack set chillroomscan = dateadd(day,1,chillroomscan)
where chillroomscan < racked 

Open in new window

0

Featured Post

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question