Click here to Skip to main content
15,915,094 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have a dataset, which have a column create_date which have value(5/12/2011 12.54.00) , but i want to select the value from dataset with date only not by time (i.e. 5/12/2011),
Current code:
oDatatable.Select("create_date = " & cDate(Now.date))
But it will only selecting row if the data and time both are same, but i want to select if the data is same.
Please give a solution for this,

Thanks,
Dhiraj
Posted

hi,,

so simple get date only from database once you get your date to veiwstate Now.date will append 12:00:00 AM with it

so use this in your select query while selecting create_date.

select CONVERT(VARCHAR(10), getdate(), 101) as create_date
 
Share this answer
 
you can use LINQ on dataset for this as
C#
//dt is the datatable where your data is
var qry=from row in dt.AsEnumerable()
        where row.Field<datetime>("Create_date").ToShortDateString()==DateTime.Now.ToShortDateString()
        select row;
DataTable dtFiltered=qry.CopyToDataTable();
</datetime>

I have not work on VB.Net so i am giving code for C#.Net hope you can convert it.


--Pankaj
 
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