Jump to content

[SOLVED] Easy Question : MySql Query


hoopplaya4

Recommended Posts

Here's an easy question (I think).

 

Is it possible, when doing a MySql Query to include a date() string?

 

For instance, if I'm doing:

 

SELECT * FROM table WHERE field LIKE 

 

Would it be possible to enter in something like "date(Y) after "LIKE?"  If so, what is the syntax?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/132139-solved-easy-question-mysql-query/
Share on other sites

If you need to get really specific about dates you can use this approach:

<?php
$sql = "
SELECT
    COUNT(id) as total
FROM
    table
WHERE 
    date >= FROM_UNIXTIME(".mktime(0, 0, 0, date("m"), date("d"), date("Y")).")
";
?>

 

There might be a better way, but I've used this to find things like, "How many people registered this week?" or, "How many uploads have there been today?", etc...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.