discarding seconds from the datetime display

  • HOw can I dispaly 8/20/2005 11:29:00 AM as 8/20/2005 11:29 AM .

     

    I need to discard seconds part from my date.

    Thanks.

  • Application's job to do that.

  • Presentation of data should be handled on the client side. If you must do this on the server this will work

    DECLARE @val smalldatetime

    SET @val = getdate()

    SELECT  CAST(@val AS VARCHAR) AS SM_DATE_VARCHAR

    /*

    Returns: Aug 22 2005  1:43PM for more information check BOL

    HTH

    Mike

  • I always did it by this painful process:

    @newdate=convert(varchar(4),year(date))+'-'+convert(varchar(2),month(date))+'-'+convert(varchar(2),day(date))+' '+convert(varchar(2),hour(date))+':'+convert(varchar(2),minute(date))

    I manually create dates this way to be sure that 'now' is =

    00:00 <= now <= 11:59; otherwise you might not get something if today=today.

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

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