Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Small method to calculate since time
Message
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01525501
Message ID:
01525539
Vues:
39
>>>Certainly looks like a lot of code :-}
>>>How about:
Dim earlierDate As New DateTime(2009, 9, 15, 10, 40, 20)
>>>Dim timespan As TimeSpan = DateTime.Now.Subtract(earlierDate)
>>>Dim difference As New DateTime(timespan.Ticks)
>>>Console.WriteLine("Years: {0} Months: {1} Days {2}", difference.Year, difference.Month, difference.Day)
>>>
>>
>>Thanks, but Console.WriteLine() doesn't do anything in my application.
>>
>>Also, I tried to replace that to Message.Box() but was unable do. Basically, how can we get the equivalent into a variable?
>
>Use String.Format to get the above into a variable.

In SQL Server I got
declare @d datetime = '2009-09-15 10:40:20'

select DATEDIFF(year, @d, CURRENT_TIMESTAMP) as [Years], 
DATEDIFF(month, @d, CURRENT_TIMESTAMP) as [Months], 
DATEDIFF(day, @d, CURRENT_TIMESTAMP) as [Days]
2, 25, 749
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform