on 2013 May 16 10:57 AM
I'm trying to create an IF statement but I can't get it to work in SQL Anywhere 9. Here is the SQL:
select MICROS.time_card_dtl.emp_seq, MICROS.time_card_dtl.clk_in_date_tm, MICROS.time_card_dtl.clk_out_date_tm, MICROS.time_card_dtl.reg_hrs, MICROS.time_card_dtl.job_seq, jd.name, if hour(MICROS.time_card_dtl.clk_in_date_tm) < 5 then dateadd(day, -1, (date(MICROS.time_card_dtl.clk_in_date_tm))) else date(MICROS.time_card_dtl.clk_in_date_tm) end if from MICROS.time_card_dtl inner join micros.job_def jd on jd.job_seq = MICROS.time_card_dtl.job_seq where MICROS.time_card_dtl.clk_in_date_tm between '2013-05-10 00:07:00' and '2013-05-13 04:00:00' group by MICROS.time_card_dtl.emp_seq, MICROS.time_card_dtl.clk_in_date_tm, MICROS.time_card_dtl.clk_out_date_tm, MICROS.time_card_dtl.reg_hrs, MICROS.time_card_dtl.job_seq, jd.name order by MICROS.time_card_dtl.emp_seq
I don’t know SQL Anywhere very well, but I am very familiar with MySQL. We don’t have the SQL Anywhere 9 manual, and I’ve been trying to get by with the SQL Anywhere 10 manual found here:
Request clarification before answering.
Apparently you have to use:
endif
instead of:
end if
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, that's true for the IF expression in v10 and below. Note that the IF statement is ended with END IF, in contrast.
v11 introduced the nice addition that you can use both ENDIF or END IF both for IF expressions and IF statements - cf. this doc page on v11:
BTW: DCX is a handy site to access current SQL Anywhere documentation...
Raphael, if you send me an email at breck dot carter@gmail.com I will send you the Help files for V9.
Plus, you can buy my book, it's on V9.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.