xOracle Posted August 12, 2008 Share Posted August 12, 2008 MySQL client version: 4.1.22 I know the subject seems confusing, but I didn't know how else to put it. Basically what I want is to be able to modify the mySQL value for a certain column in the WHERE section before selecting. The statement is as follows: SELECT * FROM calendar WHERE date('j', eday)= '3' AND recurring='1' eday is a timestamp in unix format (i.e: "1217566800") and I want to convert it into the day of the month before comparing it to the variable. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' eday)='date('j'' date=' 1217566800)' AND recurring='1'' at line 1[/quote'] CREATE TABLE `events` ( `id` int(255) NOT NULL auto_increment, `eday` int(15) NOT NULL default '0', `title` blob NOT NULL, `event` blob NOT NULL, `recurring` tinyint(1) NOT NULL default '0', `end_day` int(15) NOT NULL default '0', `startDate` int(10) NOT NULL default '0', `endDate` int(10) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM; Any help is appreciated, thanks. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 12, 2008 Share Posted August 12, 2008 Maybe you are confusing mysql's DATE() function -- which extracts the date portion of a DATETIME column -- and php's date function. Quote Link to comment Share on other sites More sharing options...
xOracle Posted August 13, 2008 Author Share Posted August 13, 2008 what i'm trying to do is use PHP's date() function to convert the table value then compare THAT against the WHERE statement. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 13, 2008 Share Posted August 13, 2008 what i'm trying to do is use PHP's date() function to convert the table value then compare THAT against the WHERE statement. Don't do that...mysql has built-in date functions. What's e-day? A timestamp? Quote Link to comment Share on other sites More sharing options...
xOracle Posted August 14, 2008 Author Share Posted August 14, 2008 what i'm trying to do is use PHP's date() function to convert the table value then compare THAT against the WHERE statement. Don't do that...mysql has built-in date functions. What's e-day? A timestamp? This table is for a calendar. eday is a timestamp of when the event occurs, but there is also an option for the user to choose that the event will occur on the same day of every month or every year, so what I want to do is select all the events that share the same day as the value in the WHERE part. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 14, 2008 Share Posted August 14, 2008 Then DAYOFWEEK(FROM_UNIXTIME(eday)) is the expression you want. Quote Link to comment Share on other sites More sharing options...
xOracle Posted August 15, 2008 Author Share Posted August 15, 2008 DAYOFWEEK? Is there like a DAYOFMONTH function? also: Thank you so much. edit: Never mind, there is a dayofmonth function. Thank you so much for your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.