Frage

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?

War es hilfreich?

Lösung

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

Andere Tipps

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;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top