mysql - Date difference using months -


i have month names in database, eg. tomonth , frommonth. data stored 'jan', 'feb' etc.

what have difference between tomonth , frommonth?

try below query

select (tomonth-frommonth) monthdiff ( select case when `frommonth` = 'jan' 1     when frommonth = 'feb' 2      when frommonth = 'mar' 3     when frommonth = 'apr' 4      when frommonth = 'may' 5      when frommonth = 'jun' 6      when frommonth = 'jul' 7      when frommonth = 'aug' 8      when frommonth = 'sep' 9      when frommonth = 'oct' 10      when frommonth = 'nov' 11      when frommonth = 'dec' 12     end frommonth,  ( case when tomonth = 'jan' 1    when tomonth = 'feb' 2      when tomonth = 'mar' 3     when tomonth = 'apr' 4      when tomonth = 'may' 5      when tomonth = 'jun' 6      when tomonth = 'jul' 7      when tomonth = 'aug' 8      when tomonth = 'sep' 9      when tomonth = 'oct' 10      when tomonth = 'nov' 11      when tomonth = 'dec' 12     end ) tomonth table) 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -