Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i have to problem to convert date (dd/mm/yyyy 00:00:00 am) to mm/dd/yyyy in where condition to compare two date in Linq.
please help me
Posted
Comments
StianSandberg 23-Apr-13 7:21am    
In where condition as in your sql-query?
TrushnaK 23-Apr-13 7:29am    
Show how you convert?
[no name] 23-Apr-13 7:46am    
Okay and so what would be the problem?

In your database you should keep dates as dates. There's no need to convert dates to a specific string in your database. Treet data as data and do converting and formatting in your application.

Compare dates:

C#
date1.ToString("yyyyMMddHHmm") == date2.ToString("yyyyMMddHHmm")

ToString(format) depends on how accurate the comparing should be.

What have you tried?
 
Share this answer
 
v3
Comments
bbirajdar 23-Apr-13 7:35am    
+ed
StianSandberg 23-Apr-13 7:40am    
thx
something like this
dateObj1.ToString("mm/dd/yyyy") = dateObj2;
where dateObj2 is of format "mm/dd/yyyy"
 
Share this answer
 
v3
Comments
bbirajdar 23-Apr-13 7:36am    
The OP says LINQ .. Not SQL
Convert.ToDateTime( "Your data time").ToString("MM/dd/yyyy");
 
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