[thelist] SQL query help
Tarrant Costelloe
taz at insur-e.net
Fri Nov 8 06:21:02 CST 2002
Hmmmm no it's not. This is what my code looks like however I cannot get the
cast to work in the query.
------------------------------------------
<?
$PopularBlogWeekQuery="SELECT * from blogs WHERE blog_author =
\"$member_username\" AND datepart(mm, blog_date) = 12 ORDER BY blog_hits";
$PopularBlogWeekResult=mysql_db_query($database,$PopularBlogWeekQuery,$link)
;
while ($PopularBlogWeekRow=mysql_fetch_array($PopularBlogWeekResult))
{
$PopularBlogWeekCount++;
if($PopularBlogWeekCount++ < 2)
{
echo $PopularBlogWeekRow[blog_subject];
}
}
?>
----------------------------------------
Any ideas? blog_date is a DATE field.
On running this I get the error. "Supplied argument is not a valid MySQL
result resource on line 15" which is this:
while ($PopularBlogWeekRow=mysql_fetch_array($PopularBlogWeekResult))
Thanks.
-----Original Message-----
From: listman at hazard0us.org [mailto:listman at hazard0us.org]
Sent: 08 November 2002 11:45
To: thelist at lists.evolt.org
Subject: RE: [thelist] SQL query help
If you are using SQL Server you can use datepart () :
Select * from TableName
Where datepart(mm, DATE) = 12
Order by hits
will fetch all the records from TableName for the month of december.
Access also has a datepart function , you have to put the mm in quotes
like this :
datepart("mm", Date)
Note : if your DATE field is not of data type DATETIME you will
need to cast() or convert() it explicitly into a datetime type.
HTH
ashok
------
Ashok Hariharan
http://www.unganisha.org
------
--
For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !
Please support the community that supports you.
http://evolt.org/help_support_evolt/
More information about the thelist
mailing list