Click here to Skip to main content
11,637,662 members (85,512 online)
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 1: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)

  Print Answers RSS
0 jyo.net 380
1 Sergey Alexandrovich Kryukov 309
2 stibee 308
3 OriginalGriff 230
4 sasanka sekhar panda 190
0 OriginalGriff 9,031
1 Sergey Alexandrovich Kryukov 8,763
2 Mika Wendelius 6,999
3 F-ES Sitecore 2,388
4 Suvendu Shekhar Giri 2,320


Advertise | Privacy | Mobile
Web04 | 2.8.150728.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