| Author |
Topic |
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2007-03-02 : 01:23:19
|
| hi this is my query:select from projectmaster where project_start_date between convert(datetime,@fromdate,103) and convert(datetime,@todate,103)so i have the following date in my table:select project_start_date from projectMasterproject_start_date----------------------2007-02-27 16:53:27.0002007-02-28 13:05:52.0032007-03-01 09:22:09.0002007-03-01 14:09:23.0002007-03-01 15:54:15.9802007-03-01 16:08:15.2972007-03-01 14:03:39.000 here my problem is if run the first query i am getting records of these two dates only:2007-02-27 16:53:27.0002007-02-28 13:05:52.003for example select from projectmaster where project_start_date between convert(datetime,'27-02-2007',103) and convert(datetime,'01-03-2007',103) i am getting only two rows but i need all the rows has to be dispplayed. please help me to achieve my need. |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-02 : 01:29:37
|
| [code]Where dateadd(d, 0, datediff(d, 0, project_start_date)) between '20070227' and '20070301'[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2007-03-02 : 01:45:48
|
| hi harsh_athalye, i am passing date as dd/mm/yyyy(27-02-2007) from my frontend but u used another format(20070227).can u please Where dateadd(d, 0, datediff(d, 0, project_start_date)) between '20070227' and '20070301'how to use my dateformat(dd/mm/yyyy) to pass here? |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-02 : 02:19:30
|
| [code]Where dateadd(d, 0, datediff(d, 0, project_start_date)) between convert(datetime, '27-02-2007', 105) and convert(datetime, '01-03-2007', 105)[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-02 : 03:12:49
|
| Use DATETIME parameters in the stored procedure for handling dates and times correctly.Do not use VARCHAR for this.Peter LarssonHelsingborg, Sweden |
 |
|
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2007-03-02 : 03:14:01
|
| hi harsh,i used ur query it dint dive reords,i am getting empty only but i have values in that.select project_start_date from projectMasterproject_start_date----------------------2007-02-27 16:53:27.0002007-02-28 13:05:52.0032007-03-01 09:22:09.0002007-03-01 14:09:23.0002007-03-01 15:54:15.9802007-03-01 16:08:15.2972007-03-01 14:03:39.000i used this query:select * from projectmaster Where dateadd(d, 0, datediff(d, 0, project_start_date)) between convert(datetime, '27-02-2007', 105) and convert(datetime, '01-03-2007', 105) but i am not getting answer empty row only shown,please help me |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-02 : 03:18:22
|
| select *from projectmasterWhere project_start_date >= '20070227'and project_start_date < '20070302'Peter LarssonHelsingborg, Sweden |
 |
|
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2007-03-02 : 03:23:01
|
| hi peso, i used this query:select *from projectmasterWhere project_start_date >= convert(datetime, '27-02-2007', 105)and project_start_date < convert(datetime, '01-03-2007', 105) why i am converting here is i am passing date as dd/mm/yyy formatbut i am getting empty recods only,so please help me |
 |
|
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2007-03-02 : 03:31:17
|
| hi peso,i used this:select project_start_datefrom projectMasterWhere project_start_date >= convert(datetime, '22-02-2007', 105)and project_start_date < convert(datetime, '02-03-2007', 105) i am getting only two values:project_start_date----------------------2007-02-26 13:55:59.0932007-02-28 13:56:49.923but i have the following values in my table:project_start_date----------------------2007-03-02 13:27:49.9732007-02-26 13:55:59.0932007-02-28 13:56:49.9232007-03-02 13:28:46.5132007-03-02 13:55:05.9072007-02-27 14:01:44.0932007-03-02 13:47:11.063 so what is the problem why i couldn't get help me |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-02 : 03:43:49
|
quote: Originally posted by sqllover select project_start_datefrom projectMasterWhere project_start_date >= convert(datetime, '22-02-2007', 105)and project_start_date < convert(datetime, '02-mar-2007')
Peter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-02 : 03:44:11
|
| select project_start_datefrom projectMasterWhere project_start_date >= convert(datetime, '22-02-2007', 105)and project_start_date < convert(datetime, '03-mar-2007')Peter LarssonHelsingborg, Sweden |
 |
|
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2007-03-02 : 04:02:11
|
| hi peso, i am passing date in dd/mm/yyyyu used as 03-mar-2007 so how can i convert 03/03/2007 as 03-mar-2007 and u used 03-mar-2007 so that i can getall the values but i have 02/03/2007 so why u have given 03 as date.can't we give 02 as date na.becos i have records like this:project_start_date----------------------2007-03-02 13:27:49.9732007-02-26 13:55:59.0932007-02-28 13:56:49.9232007-03-02 13:28:46.5132007-03-02 13:55:05.9072007-02-27 02:01:44.0002007-03-02 13:47:11.063noe u can clear my queston |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-02 : 04:31:46
|
| The TIME part when only given dd/mm/yyyy is 00:00:00.000.You have several records with the same date for March 2nd, but the TIME is between 1 and 2 pm.So when you compare with only 02/03/2007, you miss out the records in the afternoon.Therefore you should compare with the following day and have all records LESS than following day.Peter LarssonHelsingborg, Sweden |
 |
|
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2007-03-02 : 04:33:19
|
| ok peso thanks for your big coneversation nice reply |
 |
|
|
|