Solved

datetime manupulation

Posted on 2006-06-27
5
196 Views
Last Modified: 2010-04-23
I wanna know the difference between two time variables:
1. char type as fetch from the datetime field from a table as follows:
select top 1 CONVERT(CHAR(5), myTime, 114) as newTime from table1
ex:10:30 (10 hour 30 min am)

2. time from system date as follows:
system.now.hour    = 11
system.now.minutes = 40

solution:
giventime - currenttime
ex: 10.30 - 11.40
note: difference in minutes

I want to know the different between these two variables.
Anyone who can suggest very simple code for this solution?


0
Comment
Question by:peterdevadoss
  • 2
5 Comments
 
LVL 7

Expert Comment

by:pradeepsudharsan
Comment Utility
 Dim a As DateTime = New DateTime(2006, 1, 1, 11, 30, 0)
        Dim a1 As String = Now.Subtract(a).Hours.ToString()
        Dim a2 As String = Now.Subtract(a).Minutes.ToString()
        Dim a3 As String = Now.Subtract(a).Seconds.ToString()
0
 
LVL 7

Accepted Solution

by:
pradeepsudharsan earned 50 total points
Comment Utility
Dim a As DateTime = New DateTime(2006, 1, 1, 11, 30, 0)
        Dim a1 As String = (((Now.TimeOfDay.Hours - a.TimeOfDay.Hours) * 60) + (Now.TimeOfDay.Minutes - a.TimeOfDay.Minutes)).ToString() + " minutes"
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now