30 minute difference from two dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nityaprashant
    New Member
    • Feb 2008
    • 19

    30 minute difference from two dates

    Hello..

    i have two dates one is trdate e.g. "2008-02-20 12:55:25.000" (sql server format)
    another one is currdate system current time (date.now)

    if time passed more than 30 minutes than trdate
    means cuurdate' time is 30 more than the trdate's time then i want to delete that record..

    but i don't to how to fatch 30 mins difference from both dates..

    both dates r as datetime

    could u plz help me?

    thanking u in advaced...
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi there,

    You can use the AddMinutes function of the DateTime data type. Like this:

    Code:
     dim trDate As DateTime = "2008-02-20 12:55:25.000" 
    Dim currDate As DateTime = Date.Now
     
    If currDate >= trDate.AddMinutes(30) Then
     
    'DELETE RECORD IN HERE
     
    End If
    Hope this helps,

    Dr B

    Comment

    • YGayatri
      New Member
      • Nov 2007
      • 9

      #3
      Hi,

      Date difference can be fetched as below.

      DECLARE @A AS DATETIME
      DECLARE @B AS DATETIME
      SET @A = '2007-11-20 17:06:27.377'
      SET @B = '2007-11-20 12:41:38.203'
      SELECT @a,@b,DATEDIFF( N,@B,@A) minutediff

      Regards,
      Gayatri.

      Originally posted by nityaprashant
      Hello..

      i have two dates one is trdate e.g. "2008-02-20 12:55:25.000" (sql server format)
      another one is currdate system current time (date.now)

      if time passed more than 30 minutes than trdate
      means cuurdate' time is 30 more than the trdate's time then i want to delete that record..

      but i don't to how to fatch 30 mins difference from both dates..

      both dates r as datetime

      could u plz help me?

      thanking u in advaced...

      Comment

      • nityaprashant
        New Member
        • Feb 2008
        • 19

        #4
        Thanks Gayartri..

        i had done date difference with ur kind help..

        once again thanks...

        bye!


        Originally posted by YGayatri
        Hi,



        Date difference can be fetched as below.

        DECLARE @A AS DATETIME
        DECLARE @B AS DATETIME
        SET @A = '2007-11-20 17:06:27.377'
        SET @B = '2007-11-20 12:41:38.203'
        SELECT @a,@b,DATEDIFF( N,@B,@A) minutediff

        Regards,
        Gayatri.

        Comment

        • nityaprashant
          New Member
          • Feb 2008
          • 19

          #5
          Hello..

          first of all thanks for help me..

          i need more help from u..

          could u plz help me?

          i have template column inside grid view..

          in that one link button called Remove this? when i click on that link button confirmation box like "Are u sure u want to remove this?" is appeared..

          now in template column product name is also in label..

          so now i want that when i click on particular row's link button(Remove this?) then confirmation displayed like "Are u sure u wnat to remove this Bangjadtar?(Product Nmae) Dynamically for each row..

          what i had done is pasted below...(in vb.net)

          Sub ComputeSum(ByVa l sender As Object, ByVal e As GridViewRowEven tArgs) Handles GridView1.RowDa taBound
          Dim dgitem As GridViewRow
          Dim lnkbtnremove As LinkButton

          Dim a As Label

          For Each dgitem In GridView1.Rows
          a = dgitem.FindCont rol("lblinprodn ame")
          lnkbtnremove = dgitem.FindCont rol("lnkRemove" )
          'b = GridView1.Rows. Item().RowIndex

          lnkbtnremove.At tributes.Add("o nclick", "return confirm('Are you sure you want to Remove?')")
          Next

          '' ''objpropproduc tmaster.prod_id = a.Text
          '' ''ds = objbalproductma ster.fatchprodu ctnamedelete(ob jpropproductmas ter)
          '' ''For Each dr In ds.Tables(0).Ro ws
          '' '' b = dr(0)
          '' ''Next

          '' ''Dim i As Integer
          '' ''Dim name As Label
          '' ''For i = 0 To i < GridView1.Rows. Count - 1
          '' '' name = GridView1.Rows( i).FindControl( "lblinprodname" )
          '' ''Next
          End Sub


          -------------------

          'for deleting particular item from cart
          Public Function del(ByVal prodid As String, ByVal transid As String)
          objpropTransact ion.trans_id = transid
          objpropTransact ion.prod_id = prodid
          objbalTransacti on.DeleteItemFr omCart(objpropT ransaction)
          End Function

          'when particular button is clicked within cart
          Protected Sub GridView1_RowCo mmand(ByVal sender As Object, ByVal e As System.Web.UI.W ebControls.Grid ViewCommandEven tArgs) Handles GridView1.RowCo mmand
          If (e.CommandName = "del") Then
          Dim prodid As String
          prodid = e.CommandArgume nt
          Dim prodname As String
          prodname = e.CommandArgume nt
          del(prodid, storeidcheck)
          bindgrid()
          If GridView1.Rows. Count <= 1 Then
          Session.Add("ca rtempty", "True")
          End If
          End If
          End Sub

          ----
          but it gives only last row's product name...

          i want each row's column name...
          plz help me..

          check bold letters also..bez computesum handels gridview1.rowbo und event...so

          thanking u in advanced..

          Regards..
          Nitya


          Originally posted by DrBunchman
          Hi there,


          You can use the AddMinutes function of the DateTime data type. Like this:

          Code:
           dim trDate As DateTime = "2008-02-20 12:55:25.000" 
          Dim currDate As DateTime = Date.Now
           
          If currDate >= trDate.AddMinutes(30) Then
           
          'DELETE RECORD IN HERE
           
          End If
          Hope this helps,

          Dr B

          Comment

          Working...