sql - Calculating current school year -


i trying calculate current school year is, based off of sysdate.

since academic school years run (approximately) august - may, need @ current month determine school year in.

for example, if current month may of 2013, 2012-2013 school year. however, if current month september of 2013, 2013-2014 school year.

i suspect approach way off , there easier way accomplish this, here portion of sql code working now:

where to_date(ps_customfields.getstudentscf(s.id,'voltran_expdate'),'mm/dd/yyyy') between   case      when to_char(sysdate,'mm') < '08' '08/01'||(to_char(sysdate,'yyyy')-1) , '08/01/'||to_char(sysdate,'yyyy')      when to_char(sysdate,'mm') >= '08' '08/01'||to_char(sysdate,'yyyy') , '08/01/'||(to_char(sysdate,'yyyy')+1) end 

the ps_customfields.getstudentscf(s.id,'voltran_expdate') field plain text field, why i'm casting date.

the error i'm getting in sqldeveloper specific code "ora-00905: missing keyword", haven't been able pin down i'm missing.

can suggest more elegant way accomplish this???

thank you

result of case value, not range. if understood question right need 2 cases (also, seems second when can replace else):

where to_date(ps_customfields.getstudentscf(s.id,'voltran_expdate'),'mm/dd/yyyy')  between       case      when to_char(sysdate,'mm') < '08' '08/01'||(to_char(sysdate,'yyyy')-1)      else '08/01'||to_char(sysdate,'yyyy')   end ,  case      when to_char(sysdate,'mm') < '08' '08/01/'||to_char(sysdate,'yyyy')      else '08/01/'||(to_char(sysdate,'yyyy')+1)  end 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -