|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Date to String in SQL statement
Hi,
I have to be able to execute an sql statement which would look something like this. SELECT * FROM Table1 WHERE start_date LIKE '*01*' The problem is this does not work since start_date is from the type date. How can I convert the start_date field to a string in order to execute the where clause? |
|
#2
|
|||
|
|||
|
Hi,
This depends on what you want to do...I can't promise you these will all work since this is untested, but it's along these ideas to check out.... If you're not worried about the year: -- e.g. For January SELECT * FROM MyTable WHERE MONTH(DateField) = 1 Or, if you do need to limit to a specific year: a) -- e.g. for January 2003 SELECT * FROM MyTable WHERE MONTH(DateField) = 1 AND YEAR(DateField) = 2003 b) -- e.g. for January 2003 SELECT * FROM MyTable WHERE DateDiff(m, DateField, '2003-01-01') = 0 also check out some other date functions that may help you, google around for date functions |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > Date to String in SQL statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|