Date format in Sqlserver

  • Below is the query it works fine without the last 'AND' condition but when that condition is applied domainid,urlid,applicationargumentid values are nulls.

    First Question: the 'requestdate' format in tables are of 'YYYY-MM-DD HH:MI:SS.MMM(24h)'

    how can i modify the query according to the date format

    Second Question: Let me know if the query is properly framed.

    select s.domainid,d.domain,s.urlid,u.url,s.applicationargumentid

    from stats s,idomain d,iurl u

    where s.domainid =* d.domainid

    and s.urlid =* u.urlid

    and requestdate = '2008-07-30'

  • Heres all you need to know about dates in Sqlserver

    http://www.karaszi.com/SQLServer/info_datetime.asp



    Clear Sky SQL
    My Blog[/url]

  • thanks for the info on the datestamps.

    But query is taking lot of time to run , can it be tuned to run more faster.The query is

    select s.domainid,d.domain,s.urlid,u.url,s.applicationargumentid,a.application_argument

    from stats s,idomain d,iurl u,iapplicationargument a

    where s.domainid =* d.domainid

    and s.urlid =* u.urlid

    and s.applicationargumentid =* a.applicationargumentid

    and (requestdate between '2008-07-30 00:00:00.000' and '2008-07-30 23:59:59.999')

  • Please see this link[/url] on how to post performance issues...



    Clear Sky SQL
    My Blog[/url]

  • Blazix Marler (7/17/2009)


    thanks for the info on the datestamps.

    But query is taking lot of time to run , can it be tuned to run more faster.The query is

    select s.domainid,d.domain,s.urlid,u.url,s.applicationargumentid,a.application_argument

    from stats s,idomain d,iurl u,iapplicationargument a

    where s.domainid =* d.domainid

    and s.urlid =* u.urlid

    and s.applicationargumentid =* a.applicationargumentid

    and (requestdate between '2008-07-30 00:00:00.000' and '2008-07-30 23:59:59.999')

    Is requestdate defined as datetime data type?

    In fact, please provide the DDL for the tables involved in the query including indexes, sample data for the tables, the actual execution plan for the query.

    For help on all of this, please read the first two articles I reference below in my signature block.

  • I was also looking at your code, what version of SQL Server are using? I'm guessing that it is SQL Server 2000, not SQL Server 2005. If it is SQL Server 2005, then your database is probably using compatibility mode 80.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply