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 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 295
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 184
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.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