Home > DeveloperSection > Forums > FInd current data from table in sql server?
lois waisbrooker
lois waisbrooker

Total Post:70

Points:494
Posted on    May-16-2013 3:30 AM

 MSSQL Server MSSQL Server 
Ratings:


 1 Reply(s)
 844  View(s)
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.


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    May-16-2013 8:20 AM

Hi Lois!

Try as following

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

I hope it helpful to you.

Don't want to miss updates? Please click the below button!

Follow MindStick