Jump to content

how to sort by a date range?


flyclassic

Recommended Posts

Hi,i've a logic question anybody can help??

if i've following mysql database
(primary key id, `date_entry` datetime default NULL,)
id | information | date_entry |
01| handsome | 2006-06-24 18:06:19 |
02| handsome1 | 2006-06-24 18:36:12 |
03| handsome 2 | 2006-06-23 19:06:13 |
etc...


I want to select * columns from date 2006-06-24 only regardless of time OR how do i select by a given date range, how do i go about doing that? any help will be greatly appreciated. THanks
Link to comment
https://forums.phpfreaks.com/topic/12795-how-to-sort-by-a-date-range/
Share on other sites

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--]... [color=green]WHERE[/color] DATE_FORMAT(date, [color=red]'%Y[span style=\'color:orange\']-[/color]%m[color=orange]-[/color]%d'[/span]) [color=orange]=[/color] [color=red]'2006[span style=\'color:orange\']-[/color]06[color=orange]-[/color]24'[/span] [!--sql2--][/div][!--sql3--]
or
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--]... [color=green]WHERE[/color] date BETWEEN [color=red]'2006[span style=\'color:orange\']-[/color]06[color=orange]-[/color]24 00:00:00'[/span] [color=blue]AND[/color] [color=red]'2006[span style=\'color:orange\']-[/color]06[color=orange]-[/color]24 23:59:59'[/span] [!--sql2--][/div][!--sql3--]
[!--quoteo(post=387580:date=Jun 24 2006, 05:45 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Jun 24 2006, 05:45 PM) [snapback]387580[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--]... [color=green]WHERE[/color] DATE_FORMAT(date, [color=red]'%Y[span style=\'color:orange\']-[/color]%m[color=orange]-[/color]%d'[/span]) [color=orange]=[/color] [color=red]'2006[span style=\'color:orange\']-[/color]06[color=orange]-[/color]24'[/span] [!--sql2--][/div][!--sql3--]
or
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--]... [color=green]WHERE[/color] date BETWEEN [color=red]'2006[span style=\'color:orange\']-[/color]06[color=orange]-[/color]24 00:00:00'[/span] [color=blue]AND[/color] [color=red]'2006[span style=\'color:orange\']-[/color]06[color=orange]-[/color]24 23:59:59'[/span] [!--sql2--][/div][!--sql3--]
[/quote]


PHEW!, this is cooly great help! THANK YOU GUYS!
if you have a sql question, just cross your fingers and pray that barand will descend upon your thread.

I swear he wrote the sql language [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]

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.