Adam Posted May 28, 2009 Share Posted May 28, 2009 Hi all. I'm fairly new to MSSQL (but not MySQL) and having a few troubles selecting records from a certain date. I've currently got: select t1.order_create_date, t1.orderno, t1.prodcode, t2.invcost, t1.qtyord, t1.curcost from iuk_ord_detail t1, iuk_ord_hd t2 where t1.salesno = '898' and t1.orderno = t2.orderno This works perfect. Now though like I said, I'd like to only select records from a certain date, going by the "order_create_date" field which is 'datetime' data type. I've tried adding (for example): and order_create_date = '05 May, 2009' But this returns 0 records, even though there is at least 1 record with the value of "2008-05-20 15:51:00.000". I don't suppose anybody has any clue why not? EDIT: I managed to get it working when I use: t1.order_create_date between '2008-05-20 00:00:00.000' and '2008-05-20 23:59:59.000' ... but I'd prefer to have a 'date = _date_' kind of solution if possible. Thanks for any help, Adam Quote Link to comment Share on other sites More sharing options...
corbin Posted May 28, 2009 Share Posted May 28, 2009 Two things.... I don't know if MSSQL will handle the format "05 May, 2009." Also, with datetime, 05 May, 2009 != 2008-05-20 15:51:00.000. When ever a time is excluded, I'm sure 00:00:00 is assumed. (Also, you meant for the years to match right???) Quote Link to comment Share on other sites More sharing options...
cltn77 Posted June 2, 2009 Share Posted June 2, 2009 try to use substring(order_create_date,0,10)='2008-05-20' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.