Internal clock times and datediff query

  • Hi

    i have to generate a key in a table by way of concatination.

    exmaple key : CLINC:CONS:09/09/2010:CRN:15:30:00

    the problem i have is that i wish to show the time as the internal clock formats, in seconds past midnight so would expect to see ......

    exmaple key : CLINC:CONS:09/09/2010:CRN:38700

    Does anyone have any ideas????

    Thanks in advance

  • To get the date portion, cast your date value as date. To get the seconds, use DATEDIFF to find the seconds between the date value and the date portion that you have just obtained.

    Why do you want to use this as a key? Having such a wide key is likely to have an adverse effect on performance. Why not just use an identity column and store the values that you use to generate the key in separate columns?

    John

  • Many Thanks. All sorted now.

    Dont ask about the key, we're linking to a very old system and thats the key it uses. it is a one off job so performance is not an issue.

    Thanks again.

  • Thanks for posting back. It's customary in situations like this for you to post some code or a description of how you fixed it, please, in case someone else has a similar now or in the future.

    John

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

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