0

I have the following code:

if (filtro.FinalDate != null)
            {
                FinalDate = String.Format(" Data <= '{0}' ", filtro.FinalDate.GetValueOrDefault().ToString("yyyy-MM-dd") + " 23:59:59");
            }

But when I compile and type something in the FinalDate, the following message appears in the log:

Could not convert string to DateTime: 18/11/2014. Path 'FinalDate', line 1, position 102.

3
Contributors
2
Replies
21
Views
2 Years
Discussion Span
Last Post by isozworld
0

The problem in your code is in the date part. Becuase there is no 18. month.
if you set a varialbe which tooks your date first, the problem will be solved.
Before doing this, first set your day month and year of your fitro object
The code below works.

        DateTime FinalDate=DateTime.Now;//your fitro object date will be here
        string xdate = String.Format(" Data <= '{0}' ", FinalDate.ToString("yyyy-MM-dd") + " 23:59:59");
        Text = xdate;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.