|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL statement to search and sort by month?
I have a field in my table on my MSSQL server with dates, formatted like:
09/09/2004 Is there a way I can just pull the items for the current month? Something like Select * FROM table Where date_field LIKE "today" I will be using asp to query the DB if that helps Thanks! Marcus |
|
#2
|
|||
|
|||
|
I'm sure there is something easier, but this should work:
select * from table where date_field like '09/09/%' and date_field like '%/2004' |
|
#3
|
||||
|
||||
|
Returns all records where the date_field's month and year equal the current month and year.
Code:
SELECT * FROM TableName WHERE Month(date_field) = Month(GetDate()) AND Year(date_field) = Year(GetDate()) |
|
#4
|
|||
|
|||
|
Thanks to both for the responses.
Mem: Will this work fine if the date type on the server is "short date"? |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > SQL statement to search and sort by month? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|