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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.