Click here to Skip to main content
15,900,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i used a query to get data from database depending upon the datetime property

the query was like

C#
string sql = "select * from   tblVehicle where CAST(floor( CAST( Vehentrytime AS FLOAT ) )AS DATETIME) = '" + myDate + "" + "'";


here i got the string for myDate as
C#
string myDate = System.DateTime.Now.ToString("MM/dd/yyyy");

now i want to get all records selecting datas of a month or may be year also

i tried like

C#
string myDate = System.DateTime.Now.ToString("MM/yyyy");

but encountered some error saying conversion failed
since my system time is in format mm/dd/yyyy how can i obtained my desired values
with regards bishnu
Posted
Updated 3-Nov-11 1:45am
v2
Comments
Amir Mahfoozi 3-Nov-11 7:45am    
Why does the Vehentrytime field has a such complicated value ? :o

The answers to this question[^] might help you out.
 
Share this answer
 
Use DatePart() of SQL SERVER
 
Share this answer
 

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