Re: date + 1 ???



thanks
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@xxxxxxx> wrote in message
news:1138665436.223913.75090@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Edward wrote:
>
>> Hi group,
>>
>> Using Oracle, and given that $date=30/01/2006, you can construct a query
>> as
>> follows:
>>
>> select * from table
>> where date_field between to_date('$date', 'dd/mm/yyyy') and
>> to_date('$date',
>> 'dd/mm/yyyy')+1
>>
>> What is the equivalent with MSSQL?
>>
>> Thanks,
>>
>> Edward
>
> DECLARE @date DATETIME ;
> SET @date = '20060130' ;
>
> SELECT *
> FROM table
> WHERE date_col >= @date
> AND date_col < DATEADD(DAY,1,@date) ;
>
> In SQL Server DATETIME / SMALLDATETIME always includes time as well as
> date. The above query restricts to a 24hr daterange so adjust the
> DATEADD or < accordingly if that isn't what you intended.
>
> --
> David Portas, SQL Server MVP
>
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
>
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>


.



Relevant Pages

  • Re: date + 1 ???
    ... Edward wrote: ... > What is the equivalent with MSSQL? ... In SQL Server DATETIME / SMALLDATETIME always includes time as well as ...
    (comp.databases.ms-sqlserver)
  • RE: any good idea about Update many records in one page, one batch
    ... you can go for XML in database (SQL Server 2000) ... Thanks & regards, ... K.V.Ravindra Kumar ... "Edward" wrote: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: VB transformation to SQL Server datetime
    ... I understand the ramifications of the SQL Server datetime column ... And I understand that I might have to handle this through SQL Server ... If your date is in a STRING, ...
    (microsoft.public.vb.general.discussion)
  • earlier wins
    ... Microsoft SQL Server DATETIME Conflict ... Resolver. ...
    (microsoft.public.sqlserver.replication)
  • MS SQL server and SQL DATETIME manipulation in perl
    ... I am going to be doing a lot of work with Microsoft SQL Server 2000 ... using perl and the Win32::ODBC module. ... date and time conversions, and as such I was wondering if anyone has ... come up with a modulefor converting between SQL Server DATETIME ...
    (comp.lang.perl.modules)