Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi team,

I have an SQL Server 2008.

I have created table with few columns including date.

my table looks like:-

Name 28/04/2013 29/04/2013 30/04/2013 Time .. ... ...

What i need is how do i select all information where name and date is today?

for example

Name 28/04/2013 29/04/2013 30/04/2013 Time .. ... ...
xx 123 667 233 11:00 .. ... ...
yy 888 666 55 09:00 .. ... ...

i need to query which will get all values where name is = to xx and current date's coloumn value.

my output should be like for today 30-04-2013

xx 233 11:00
i use vb.net as front end

Please help me.
Posted
Comments
maxrockM 29-Apr-13 23:32pm    
Never heard of keeping dates as column names. Could have kept another table right?

1 solution

Try this:
SQL
SELECT * FROM Table1 WHERE CONVERT(DATE,CONVERT(DATETIME, YourColumnName, 103))=CONVERT(DATE, GETDATE()) AND Name='YourParameter'



--Amit
 
Share this answer
 
v2
Comments
maxrockM 29-Apr-13 23:37pm    
CONVERT(DATETIME,'01/04/2013') returns 4th Jan when you were expecting 1st April
_Amy 29-Apr-13 23:42pm    
OP will have to use SELECT convert(datetime, '01/04/2013', 103). I updated my solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900