minus hours from current time

  • how do i minus 12 hours from current time

  • More than 1 way to do it, but I find the easiest to write is:-

    SELECT getdate() - 0.5

    This subtracts half a day from the current date

  • Hi Ian,

    thanks can you give me one another method and also how i can get only the time part from a date

  • Hi,

    This sounds like homework.....:hehe:

    Take a look at the DATEADD and DATEPART functions in BOL. :w00t:



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

  • select right(Convert(varchar(20),getdate()),7) will give the timepart of a datetime variable.

  • dateadd(hour, -12,getdate()) is an example also

Viewing 6 posts - 1 through 5 (of 5 total)

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