add minutes in datetime column

  • Hi Friends. Need help for adding minutes in datetime colum.

    Example, I am having column StarTime with datatype Datetime. For example below.

    StartTime

    1899-12-30 07:45:00.000

    I want add 240 minutes int he above value and display that. How can i do that?

    Thanks,

    Abhas.

  • abhas (6/30/2016)


    Hi Friends. Need help for adding minutes in datetime colum.

    Example, I am having column StarTime with datatype Datetime. For example below.

    StartTime

    1899-12-30 07:45:00.000

    I want add 240 minutes int he above value and display that. How can i do that?

    Thanks,

    Abhas.

    suggest you research DATEADD

    https://msdn.microsoft.com/en-GB/library/ms186819.aspx

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • here's a coded example.

    create table #MyExample(Id int identity(1,1) not null primary key,StartTime datetime, OriginalValue varchar(30) )

    INSERT INTO #MyExample(StartTime,OriginalValue)

    SELECT '1899-12-30 07:45:00.000','1899-12-30 07:45:00.000'

    SELECT DATEADD(minute,240,StartTime) As NewTime FROM #MyExample

    UPDATE #MyExample

    SET StartTime = DATEADD(minute,240,StartTime)

    WHERE ID = 1

    SELECT * FROM #MyExample

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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