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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -