Link to home
Start Free TrialLog in
Avatar of gvilbis
gvilbis

asked on

sql, how do i run select command where issuedate is between range of date?

i would like to run select sql command with where condition which is from type of datetime and the condition "where" will be date and not datetime
issuedate is look like: 2007-03-22 00:00:00.000
what i have to change in the below sql command that it will run?

select * from cutheader where issuedate between '2007-0-22' and '2008-02-27'
Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Avatar of Frozenice
Frozenice
Flag of Philippines image

in your mysql table issuedate should be a timestamp type.

so from this..
select * from cutheader where issuedate between '2007-0-22' and '2008-02-27'


to this most probable..
select * from cutheader where issuedate >= 'strtotime(2007-0-22)' and issuedate <= 'strtotime(2008-02-27)'


please refer to http://php.net/manual/en/function.strtotime.php


BR
Frozenice
Avatar of gvilbis
gvilbis

ASKER

when i run the following:
select * from cutheader where issuedate >= 'strtotime(2007-0-22)' and issuedate <= 'strtotime(2008-02-27)'

the below error received:
Server: Msg 241, Level 16, State 1, Line 1
Conversion failed when converting datetime from character string.

please advice
SOLUTION
Avatar of qasim_md
qasim_md
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gvilbis

ASKER

receiving the below error:

Server: Msg 195, Level 15, State 10, Line 1
'date' is not a recognized built-in function name.
SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gvilbis

ASKER

i tried this also but still receiving an error:
Server: Msg 195, Level 15, State 10, Line 1
'strtotime' is not a recognized built-in function name.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gvilbis

ASKER

Server: Msg 243, Level 16, State 1, Line 1
Type date is not a defined system type.
Server: Msg 243, Level 16, State 1, Line 1
Type date is not a defined system type.
Avatar of gvilbis

ASKER

still receiving error
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gvilbis

ASKER

how do i check the version?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gvilbis

ASKER

anqelll, its working thanks all