Click here to Skip to main content
12,403,391 members (73,836 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB 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 16:55pm
Comments
maxrockM 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 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 29 Apr 2013
Copyright © CodeProject, 1999-2016
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