Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: How to get time from datetime

  1. #16
    Join Date
    Sep 2002
    Posts
    5,938
    Sure.

    Table looks like:

    col1 col2 col3 tgot
    ------ ----- ----- ------------------------
    4 a b 2003-04-08 13:08:27.860

    View's code:

    CREATE VIEW dbo.VIEW1
    AS
    SELECT col1, CONVERT(varchar(10), dbo.Table1.tgot, 20) AS EXPR1
    FROM dbo.Table1
    WHERE (col1 = '4')


    Result of select from view:

    col1 EXPR1
    ----------- ----------
    4 2003-04-08

  2. #17
    Join Date
    Apr 2003
    Posts
    8
    Coolness.
    Found out what the problem was. There are 2 dates in the view, Manual_Promise_Date and Promise_Date. Stupid me only saw the manual date.
    Using the code...convert(varchar(10), dbo.[Order].promise_date,110) AS PromiseDate... I now get the date without the time like 01-03-2003.

    What is the easiest way to format the date to appear like 01/03/2003? Can I do this in the view as well? If so how?

    Thanks again for the time.
    You rule!

  3. #18
    Join Date
    Sep 2002
    Posts
    5,938
    Then use

    ...convert(varchar(10), dbo.[Order].promise_date,101) AS PromiseDate...

  4. #19
    Join Date
    Apr 2003
    Posts
    8
    Thank you very much for all of the help. Trying to learn SQL as quickly as I can but there is soooooooo much.

    If it wasn't for this site and people like you rmiao I'd be up the creek without a select statement.

    Thanks again!

Posting Permissions

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