How to convert time in seconds to date and time using Convert

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dougancil
    Contributor
    • Apr 2010
    • 347

    #1

    How to convert time in seconds to date and time using Convert

    I have the following sql query:

    Code:
    SELECT [Employees].name, [Employees].Employeenumber,
    Convert ([Timestamp]-([LoggedIn]/1000)/60))/1440+1,"mm/dd/yy"as [DATE],
    FROM Employees INNER JOIN mOpInterval ON [Employees].Loginname1 = mOpInterval.Opname
    The data in the (timestamp) and (loggedin) fields are in seconds and I'm trying to convert them to date and time. When I try to run this query I get this error:

    Server: Msg 170, Level 15, State 1, Line 2
    Line 2: Incorrect syntax near '-'.

    and I know that it's because of the syntax of my query. Can anyone please tell me the best way to re-write this query to get the results that I am looking to get.

    Thank you

    Doug
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    I think you need to re-arrange your parenthesis...

    Happy Coding!!!

    ~~ CK

    Comment

    Working...