FIND CURRENT DATA FROM TABLE IN SQL SERVER?

lois waisbrooker

Total Post:70

Points:494
Posted by  lois waisbrooker
 1062  View(s)
Ratings:
Rate this:
Hi Guys!

I have a table, in this table every record insert with current data time column. 

My line of code as following

CREATE TABLE tblOrder
(
Order_ID INT IDENTITY PRIMARY KEY,
Order_Code INT,
Order_Date Date
)

INSERT INTO tblOrder(Order_Code,Order_Date) VALUES (542,GETDATE())
INSERT INTO tblOrder(Order_Code,Order_Date) VALUES (152,GETDATE())
INSERT INTO tblOrder(Order_Code,Order_Date) VALUES (122,GETDATE())
INSERT INTO tblOrder(Order_Code,Order_Date) VALUES (243,GETDATE())
INSERT INTO tblOrder(Order_Code,Order_Date) VALUES (102,GETDATE())

SELECT * FROM tblOrder WHERE Order_Date = GETDATE()

My problem is that above select query not return record. 
Please help.
Thanks in advance.
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: FInd current data from table in sql server?

    Hi Lois!


    Try as following

    SELECT * FROM tblOrder WHERE Order_Date = (CAST (getdate() as date))

    I hope it helpful to you.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!