简体   繁体   中英

Problems with SQL syntax DATEADD

SELECT hd.holiday_code, 
       hd.holiday_duration, 
       hdep.departure_date                                    AS 'Start Date', 
       Dateadd(day, hd.holiday_duration, hdep.departure_date) AS 'End Date' 
FROM   holiday_details hd 
       INNER JOIN holiday_departure hdep 
               ON hd.holiday_code = hdep.holiday_code

Well i've been trying to get this specific code ^ to work, but i cant figure out the dateadd syntax. It looks right from what i have research on the googles, but i always get the error ORA-00923: FROM keyword not found where expected

This is usually caused my some minor error on my part, but i cant find it after looking for about 20 minutes. Can anyone point out the error that is probably staring me in the face

Simply add the number of days with a numeric value. Another problem with your syntax is in 'Start Date' and 'End Date'; replace single quotes with double quotes. Change your query for something like this:

SELECT hd.holiday_code, 
       hd.holiday_duration, 
       hdep.departure_date AS "Start Date", 
       hdep.departure_date + hd.holiday_duration AS "End Date" 
FROM   holiday_details hd 
       INNER JOIN holiday_departure hdep 
               ON hd.holiday_code = hdep.holiday_code

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM