php - Select all records where the day of month is between 30 and 15 -
php - Select all records where the day of month is between 30 and 15 -
i have table called liabilities has next columns loan_name, institution_name, starting_date, emi, closing_date. type of starting_date
, closing_date
varchar.
i trying write query gets info (emi reminder) day of starting_date
between 30 , 15.
example:- have written next query, works in scenarios if today's date 07-11-2014. below query homecoming info next 15 days if date 30-11-2014 won't return results next 15 days. kindly check below query.
select user_id, owner_name client_name, loan_name scheme_name, institution_name institution_name, starting_date date_of_deduction, emi amount, closing_date, "liabilities" instrument (`liability`) `user_id` = '46' , (str_to_date(starting_date, "%d") between str_to_date("30-11-2014", "%d") , str_to_date("15-12-2014", "%d")) , (str_to_date(closing_date, "%d-%m-%y") >= str_to_date("30-11-2014", "%d-%m-%y"))
i want records between 30th - 15th of every month want send emails clients. have 3 records reference
1) starting date :- 17-09-2012 2) starting date :- 06-10-2010 3) starting date :- 21-08-2014
i want query return record 2 06-10-2010 since day of month between 30th , 15th.
since starting_date
field varchar , store date in dd-mm-yyyy
format, need convert starting_date
datetime using str_to_date() function below
str_to_date(starting_date, "%d-%m-%y")
then check if day of above value 30 or above, or 15 or below using dayofmonth() function
dayofmonth(str_to_date(starting_date, "%d-%m-%y")) >= 30 or dayofmonth(str_to_date(starting_date, "%d-%m-%y")) <= 15
the next query should homecoming right records
select user_id, owner_name client_name, loan_name scheme_name, institution_name institution_name, starting_date date_of_deduction, emi amount, closing_date, "liabilities" instrument (`liability`) `user_id` = '46' , (dayofmonth(str_to_date(starting_date, "%d-%m-%y")) >= 30 or dayofmonth(str_to_date(starting_date, "%d-%m-%y")) <= 15)
php mysql sql
Comments
Post a Comment