Jump to content

Selecting records from a certain date


Adam

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/160001-selecting-records-from-a-certain-date/
Share on other sites

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???)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.