Date Format

  • HI

    I am using date add Query for following method

    update OfflineExamScheduleMaster

    set edatetime=dateadd(mi,50,getdate()),

    I got the result for example...

    2016-03-24 11:52:16.207

    But i want following format

    2016-03-24 11:52:00.000

    I want Milli secong and nano second should be zero..

    Please help me Query

  • set edatetime=dateadd(mi,datediff(mi, 0, getdate()) + 50, 0)

    _____________
    Code for TallyGenerator

  • vs.satheesh (3/23/2016)


    HI

    I am using date add Query for following method

    update OfflineExamScheduleMaster

    set edatetime=dateadd(mi,50,getdate()),

    I got the result for example...

    2016-03-24 11:52:16.207

    But i want following format

    2016-03-24 11:52:00.000

    I want Milli secong and nano second should be zero..

    Please help me Query

    You can use double type conversion, first to smalldatetime and then back to datetime

    😎

    SELECT CONVERT(DATETIME,CONVERT(SMALLDATETIME,DATEADD(MINUTE,50,GETDATE()),0),0) AS edatetime

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

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