You are here: Re: SQL Between Dates « MsSQL Server « IT news, forums, messages
Re: SQL Between Dates

Posted by Roy Harvey on 09/13/06 11:43

Is DateGiven a datetime datatype? It sounds like it is a string, and
of course string comparison is from left to right, character by
character.

If you must store dates as strings - datetime is much better - the
safest way is yyyymmdd format. That is also the preferred format for
giving any date string to SQL Server as it avoids all the confusion of
October 9 vs September 10 that occurs when working internationally.

Roy Harvey
Beacon Falls, CT

On Wed, 13 Sep 2006 12:30:26 +0100, "@sh" <spam@spam.com> wrote:

>An update actually, based on the SQL you suggested I am getting all records
>returned, with no filter - including dates from 2003, 2004 etc?
>
>SELECT *
>FROM sol_session
> SELECT *
> FROM SOL_Session
> WHERE DateGiven >= '10/09/06' AND DateGiven
><= '13/09/06'
>
>Any ideas?
>
>Cheers, @sh
>
>
>"@sh" <spam@spam.com> wrote in message news:O9WdnXNmTY_5d5rYRVnyug@bt.com...
>> Ahhhhh sorry for being silly, knew it'd be something obvious, not having a
>> good week!!!
>>
>> Is it possible to use BETWEEN for such a SQL statement?
>>
>> Cheers, @sh
>>
>>
>> "Roy Harvey" <roy_harvey@snet.net> wrote in message
>> news:eipfg21v7lgkd3nk8fg5ulg1jfou2ah43l@4ax.com...
>>> On Wed, 13 Sep 2006 11:59:46 +0100, "@sh" <spam@spam.com> wrote:
>>>
>>>> WHERE DateGiven > '10/09/2006' AND <
>>>>'13/09/2006'
>>>
>>> WHERE DateGiven > '10/09/2006'
>>> AND DateGiven < '13/09/2006'
>>>
>>> You need to specify DateGiven for each comparison.
>>>
>>> Roy Harvey
>>> Beacon Falls, CT
>>
>>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация