Solved

datetime manupulation

Posted on 2006-06-27
5
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16991644
 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
ID: 16991673
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

737 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