Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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 23-Apr-13 2:20am
Comments
AlluvialDeposit at 23-Apr-13 7:21am
   
In where condition as in your sql-query?
TrushnaK at 23-Apr-13 7:29am
   
Show how you convert?
ThePhantomUpvoter at 23-Apr-13 7:46am
   
Okay and so what would be the problem?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
 
date1.ToString("yyyyMMddHHmm") == date2.ToString("yyyyMMddHHmm")
ToString(format) depends on how accurate the comparing should be.
 
What have you tried?
  Permalink  
v3
Comments
aspnet_regiis -i at 23-Apr-13 7:35am
   
+ed
AlluvialDeposit at 23-Apr-13 7:40am
   
thx
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

something like this
dateObj1.ToString("mm/dd/yyyy") = dateObj2;
where dateObj2 is of format "mm/dd/yyyy"
  Permalink  
v3
Comments
aspnet_regiis -i at 23-Apr-13 7:36am
   
The OP says LINQ .. Not SQL
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Convert.ToDateTime( "Your data time").ToString("MM/dd/yyyy");
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.150305.1 | Last Updated 23 Apr 2013
Copyright © CodeProject, 1999-2015
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