Solved

datetime manupulation

Posted on 2006-06-27
5
201 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
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

828 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