문제

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