Go Back   SitePoint Forums > Forum Index > Program Your Site > Databases > MySQL
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Dec 24, 2006, 13:08   #1
backtobasics
SitePoint Zealot
 
backtobasics's Avatar
 
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
backtobasics is offline   Reply With Quote
Old Dec 24, 2006, 13:21   #2
r937
SQL Consultant
SitePoint Award Recipient
 
r937's Avatar
 
Join Date: Jul 2002
Location: Toronto, Canada
Posts: 30,270
Quote:
Originally Posted by backtobasics View Post
Using SQL of course.
of course

but which database? oracle? db2? sybase? firebird? postgresql? access?
r937 is online now   Reply With Quote
Old Dec 24, 2006, 13:30   #3
backtobasics
SitePoint Zealot
 
backtobasics's Avatar
 
Join Date: Aug 2006
Posts: 196
MySQL
backtobasics is offline   Reply With Quote
Old Dec 24, 2006, 13:53   #4
r937
SQL Consultant
SitePoint Award Recipient
 
r937's Avatar
 
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)
note: thread moved to mysql forum
r937 is online now   Reply With Quote
Old Dec 24, 2006, 14:02   #5
backtobasics
SitePoint Zealot
 
backtobasics's Avatar
 
Join Date: Aug 2006
Posts: 196
Worked perfectly, cheers much!

Merry non-denominational winter break!
backtobasics is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 18:58.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved