Correct way for a db_query for nodes between two timestamps

In Drupal,

I have a very simple db_query. I want to look for any node created between two timestamps.

This query works fine in MySQL shell

SELECT nid as id,created as start,title FROM node WHERE created BETWEEN '1403564400' AND '1403650800'; 

This works fine in Drupal

$data = db_query("SELECT nid as id,created as start,title FROM node")->fetchAll(); echo json_encode($data); 

As soon as I add in the BETWEEN conditions below I get an Internal Server Error.

$data = db_query("SELECT nid as id,created as start,title FROM node WHERE created BETWEEN '1403564400' AND '1403650800'")->fetchAll(); 

I am unsure what I am doing wrong here, perhaps someone can point me in the right direction please!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

WordPress.com.

Up ↑

%d bloggers like this: