473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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...
Feb 20 '08 #1
4 983
DrBunchman
979 Expert 512MB
Hi there,

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

Expand|Select|Wrap|Line Numbers
  1.  dim trDate As DateTime = "2008-02-20 12:55:25.000" 
  2. Dim currDate As DateTime = Date.Now
  3.  
  4. If currDate >= trDate.AddMinutes(30) Then
  5.  
  6. 'DELETE RECORD IN HERE
  7.  
  8. End If
  9.  
Hope this helps,

Dr B
Feb 20 '08 #2
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.

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...
Feb 20 '08 #3
Thanks Gayartri..

i had done date difference with ur kind help..

once again thanks...

bye!


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.
Feb 21 '08 #4
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(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim dgitem As GridViewRow
Dim lnkbtnremove As LinkButton

Dim a As Label

For Each dgitem In GridView1.Rows
a = dgitem.FindControl("lblinprodname")
lnkbtnremove = dgitem.FindControl("lnkRemove")
'b = GridView1.Rows.Item().RowIndex

lnkbtnremove.Attributes.Add("onclick", "return confirm('Are you sure you want to Remove?')")
Next

'' ''objpropproductmaster.prod_id = a.Text
'' ''ds = objbalproductmaster.fatchproductnamedelete(objprop productmaster)
'' ''For Each dr In ds.Tables(0).Rows
'' '' 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)
objpropTransaction.trans_id = transid
objpropTransaction.prod_id = prodid
objbalTransaction.DeleteItemFromCart(objpropTransa ction)
End Function

'when particular button is clicked within cart
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs ) Handles GridView1.RowCommand
If (e.CommandName = "del") Then
Dim prodid As String
prodid = e.CommandArgument
Dim prodname As String
prodname = e.CommandArgument
del(prodid, storeidcheck)
bindgrid()
If GridView1.Rows.Count <= 1 Then
Session.Add("cartempty", "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.rowbound event...so

thanking u in advanced..

Regards..
Nitya


Hi there,


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

Expand|Select|Wrap|Line Numbers
  1.  dim trDate As DateTime = "2008-02-20 12:55:25.000" 
  2. Dim currDate As DateTime = Date.Now
  3.  
  4. If currDate >= trDate.AddMinutes(30) Then
  5.  
  6. 'DELETE RECORD IN HERE
  7.  
  8. End If
  9.  
Hope this helps,

Dr B
Feb 21 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

26
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: ...
6
by: Ashish Sheth | last post by:
Hi All, In C#, How can I get the difference between two dates in number of months? I tried to use the Substract method of the DateTime class and it is giving me the difference in TimeSpan,From...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
4
by: Yotam | last post by:
Hi, I need some help with JS. I will be grateful, if you can help me out. I have two date fields (check in, check out) and "number of days" field. I want the script to calculate automatically...
2
by: Blackmore | last post by:
I am trying to use javascript to calculate the difference between two form inputted dates and return the result to another form object. When I load up the page with the function on my web browser...
8
by: Claudia Fong | last post by:
Hi, In VB we have DateDiff to calculate the days difference between 2 dates, I was wondering if we have something like that in C#? I want to calculate for example the days difference...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi, misters which the best method for get the difference (in days) of two dates. The hour (hh:mm) don't mind, would be 00:00 for all dates. 1.) fechaUno.Substract(fechaDos).Days 2.)
3
by: prashantkuppa | last post by:
hi, iam struggling with difference between two dates of format type dd/mm/yyyy i need difference between two dates olddate(dd/mm/yyyy) - newdate(dd/mm/yyyy) and this should be in java script...
4
by: sniipe | last post by:
Hi! I am new in Python, so I count for your help. I need to get difference in months between two dates. How to do it in python? I am substracting two dates, for example date1 - date2 and I got...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.