|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Zealot
![]() ![]() Join Date: Aug 2006
Posts: 196
|
Select entrys within current month
I wish to select rows from a table which is within the current month. It is to show 'current months transactions', i.e. give a gross value of the transactions.
What is the best solution for doing this? Using SQL of course. Thanks |
|
|
|
|
|
#2 |
|
SQL Consultant
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jul 2002
Location: Toronto, Canada
Posts: 30,270
|
|
|
|
|
|
|
#3 |
|
SitePoint Zealot
![]() ![]() Join Date: Aug 2006
Posts: 196
|
MySQL
|
|
|
|
|
|
#4 |
|
SQL Consultant
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jul 2002
Location: Toronto, Canada
Posts: 30,270
|
Code:
where datecol
>= date_sub(current_date
, interval dayofmonth(current_date)-1 day)
and datecol
< date_add(
date_sub(current_date
, interval dayofmonth(current_date)-1 day)
, interval 1 month)
|
|
|
|
|
|
#5 |
|
SitePoint Zealot
![]() ![]() Join Date: Aug 2006
Posts: 196
|
Worked perfectly, cheers much!
Merry non-denominational winter break! |
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 18:58.












Linear Mode
