Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have table and have field name like machine_id , emp_id , date , [1],[2]...to [31]

i want to fetch that perticular column that column name = day from date field

ex :

25-01-2016 is a date
then
i fetch that column have name (is [25]) = day(25) in datetime

in above day is 25 so i want to return [25] no column and it's data only

how i fetch data in sql query ??
please give me query ??

What I have tried:

how i got column dynamically from sql using query ??
Posted
Updated 26-Feb-16 18:48pm

1 solution

Hi,

You can use dynamic query for get day if you want, you can use "DATEPART(dd,getdate())" function to get day from date.
and if you have date in row then you should use pivot command to get date in column.



Ashish Nigam
 
Share this answer
 
v2

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