Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL VB.NET
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 29-Apr-13 17:55pm
Comments
maxrockM at 29-Apr-13 23:32pm
   
Never heard of keeping dates as column names. Could have kept another table right?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

--Amit
  Permalink  
v2
Comments
maxrockM at 29-Apr-13 23:37pm
   
CONVERT(DATETIME,'01/04/2013') returns 4th Jan when you were expecting 1st April
_Amy at 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)

  Print Answers RSS
0 Kornfeld Eliyahu Peter 275
1 Maciej Los 204
2 Sergey Alexandrovich Kryukov 200
3 King Fisher 185
4 OriginalGriff 183
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 29 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100