datetime in SQL

Results 1 to 2 of 2

Thread: datetime in SQL

  1. #1
    Join Date
    Dec 1969

    Default datetime in SQL

    need help<BR> I have a column name Action_date defined as datetime in action_history table. In that column I hava a datetime 6/16/2000 10:07:02 AM if I look from sql server manager But when I use sql server query analyzer to retrive action_date it returns this 2000-06-16 10:07:02.003. <BR><BR>for example<BR> select action_date from action_history <BR> result<BR> 2000-06-16 10:07:02.003 <BR>so now how do I compare the date. <BR> select action_date from action_history where action_date = &#039 6/16/2000 10:07:02 AM&#039<BR> this returns me 0 record even though this date is in the record. I will really appreciate ur help I know its not an asp question but I m intending to use that queery in ASP later<BR><BR>Thanx in advance<BR>Asif<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: datetime in SQL

    It&#039s all down to date format - the only unambiguous way to specify a date/time value in SQL is to use the "ODBC canonical escape-clause syntax" which for a timestamp looks like {ts &#039yyyy-mm-dd hh:mm:ss&#039} - eg<BR><BR>select action_date from action_history where action_date = {ts &#039 2000-16-06 10:07:02&#039}<BR><BR>Dunc<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts