I've got a table that gets fed data throughout the day. When a new row is inserted, I insert the values into the table, including a column of "DateTimeCreated" with Now(). This column is a datetime.
But, if they later update the row, they send me a string value of date and time to use in a "DateTimeUpdated" column with a string datatype. And I have to use that value instead of Now().
This is not a huge deal because until recently we only stored and displayed this data. Now we need to update another column in that row - status - and set it to inactive (0) for any record that was created more than 24 hours prior. If the row was updated, we use that value instead and it's the text value.
Here's what I'm using so far and it's bombing out because of the different datatypes:
We ran this the other day and it worked...I swear it did. But it doesn't work now. Anyone have any suggestions? Thanks.
But, if they later update the row, they send me a string value of date and time to use in a "DateTimeUpdated" column with a string datatype. And I have to use that value instead of Now().
This is not a huge deal because until recently we only stored and displayed this data. Now we need to update another column in that row - status - and set it to inactive (0) for any record that was created more than 24 hours prior. If the row was updated, we use that value instead and it's the text value.
Here's what I'm using so far and it's bombing out because of the different datatypes:
Code:
update TableName SET Status = 0
WHERE CONVERT(DateTime,CONVERT(varchar(100),ISNULL(DateTimeUpdated, DateTimeCreated))) < DateAdd(d,-1,GetDate())
We ran this the other day and it worked...I swear it did. But it doesn't work now. Anyone have any suggestions? Thanks.