So I've used a range of queries to try and add 23 hours to all dates in the column 'match_date' and have received a variation of errors from all of them including syntax errors and errors stating that stats.dateadd does not exist.

update dates
set match_date=dateadd(hh,23,match_date)
where match_id >='1'

Any ideas why?

有帮助吗?

解决方案

I'm guessing you're using Oracle, and the dateadd function is not available. Try:

update dates
set match_date = match_date + interval '23' hour
where match_id >= 1

Alternatively, in SQL adding a number to a date adds that number in days. So you could also:

update dates
set match_date = match_date + 23.0/24
where match_id >= 1

其他提示

You can try the interval option to add date or time to a date variable in SQL. Also you can try the dateadd method but it is suitable for mySql where this interval option will work on all type of SQL engines like oracle, postgres etc.

update dates set match_date = match_date + INTERVAL '23 hour' where match_id >= 1;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top