quering date data type

  • Hi Guys?

    Is it possible to save only the date in a datetime  data type column of a table?

    Reason being that , when i use the getdate() to insert  a date value in a table it inserts the date ant the time eg: '2005/01/01 00:00:00'.

    and when i query the date eg: SELECT * FROM TABLENAME WHERE DATE = '2005/01/01' IT RETURNS NOTHING.

    THE SAME HAPPENS WHEN I USER THE CONVERT OPTION

    eg: CONVERT(DATETIME, '2005/01/01')

     

    PLEASE HELP !

    Thank You!

     

    Eduardo vwc

    KBS.com

     

  • See if this helps: http://www.sql-server-performance.com/fk_datetime.asp

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Here's one way. Instead of GetDate(), store this:

    CONVERT(datetime, CONVERT(varchar(8), GetDate(), 112))

  • You can use : SELECT * FROM TABLENAME WHERE DATE = '01 Jan 2005'

    it will return satisifing records. But while inserting/updating from client programs using native languages, you should take care. Always better to convert into datetime from yyyymmdd format.

    Regards,

    Ragesh Chavarattil

Viewing 4 posts - 1 through 3 (of 3 total)

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