The Dateadd function problem?????

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alexraj
    New Member
    • Jun 2015
    • 2

    The Dateadd function problem?????

    Dateadd when I used this function to add hours to time
    if I add 2 hours to time 11 pm I get time with date
    like 31/12/1899 01:21:00 am
    how can i get the time only
    thank you
  • inspectelement
    New Member
    • Nov 2014
    • 21

    #2
    Are you using Date part or Syntax?

    Comment

    • inspectelement
      New Member
      • Nov 2014
      • 21

      #3
      Code:
      DECLARE @datetime2 datetime2 = '13:10:10.1111111';
      UNION ALL
      SELECT 'hour',DATEADD(hour,1,@datetime2)
      UNION ALL
      SELECT 'minute',DATEADD(minute,1,@datetime2)
      UNION ALL
      SELECT 'second',DATEADD(second,1,@datetime2)
      UNION ALL
      SELECT 'millisecond',DATEADD(millisecond,1,@datetime2)
      UNION ALL
      SELECT 'microsecond',DATEADD(microsecond,1,@datetime2)
      UNION ALL
      SELECT 'nanosecond',DATEADD(nanosecond,1,@datetime2);

      Comment

      • inspectelement
        New Member
        • Nov 2014
        • 21

        #4
        Figure this will work? Just the times, not the date, month, etc.

        Comment

        • Alexraj
          New Member
          • Jun 2015
          • 2

          #5
          Thank sir my code like
          Txtnow.text=for mat(time,"hh:mm am|pm)
          Txtadd.text=dat eadd("h",2,Txtn ow.text)
          When the Txtnow.text=11: 00
          The value of Txtadd is old date like that in my question and time
          Thank u again

          Comment

          • inspectelement
            New Member
            • Nov 2014
            • 21

            #6
            Is it all good? No more problems?

            Comment

            Working...