Re: Dates
- From: Göran Andersson <guffa@xxxxxxxxx>
- Date: Thu, 04 May 2006 12:47:02 +0200
That doesn't matter. The SQL query is a string, so the date in it is a part of the string, not a separate DateTime value.
Frederik Vanderhaeghe wrote:
But in my SQL Server the field is of the type 'Datetime'.
Fré
"Göran Andersson" <guffa@xxxxxxxxx> wrote in message news:e3xQBL2bGHA.4900@xxxxxxxxxxxxxxxxxxxxxxxYou are implicitly converting the date to a string, that means that it's using the culture settings of the current thread. You should specifically convert the date to a string, and specify how it should be converted. You can use a CultureInfo object, a DateTimeFormat object or a specific format string.
I suggest that you use the ISO 8601 date format. It's unambigous, contrary to the dd/MM/yyyy and MM/dd/yyyy formats, that will depend on the culture settings of the database server.
...
where datum = '" + kalender.SelectedDate.ToString("yyyy-MM-dd") + "'
...
Frederik Vanderhaeghe wrote:I actually use the calendar object of asp.net. So the select is:
select *
from TBL_Bestanden_Zoeken
where datum = '" & kalender.SelectedDate & "'
But when I search in the SQL Server itself, I can't do this:
select *
from TBL_Bestanden_Zoeken
where datum = '31/12/2005'
The result of kalender.SelectedDate is '31/12/2005'. But when I search for datum = '2005/12/31' it works, but only on the SQL Server, not when I hardcode it in ASP.Net.
It's a very weird thing
Fré
"Göran Andersson" <guffa@xxxxxxxxx> wrote in message news:udW9Zx1bGHA.3908@xxxxxxxxxxxxxxxxxxxxxxxDo you just send the date as a string to the database, or is it converted to a DateTime at any stage?
Frederik Vanderhaeghe wrote:Hi,
I have made a search page on which users can search for documents. They can search by documentnumber, customername,... and also by date. Now the problem is that when a date is entered it doesn't show anything.
When I look at the SQL server Enterprise management and make a query there, the following works:
select *
from TBL_Bestanden_Zoeken
where (datum='2005-12-31')
When I code it like that in my asp.net site, that when the field is not empty, it searches for the documents with date='2005-12-31' then it doesn't give any results.
What can I do?
Fré
- Follow-Ups:
- Re: Dates
- From: Frederik Vanderhaeghe
- Re: Dates
- References:
- Prev by Date: Re: global.asax
- Next by Date: cross frame scripting
- Previous by thread: Re: Dates
- Next by thread: Re: Dates
- Index(es):
Relevant Pages
|
Loading