Quantcast
Viewing all articles
Browse latest Browse all 2703

Is possible make this query dates?

Hi, I have do a query VBNET with a date range. As follows:

Function sTiempo(dInit As Date, dend As Date) As String
sTime = Str((DateDiff("s", dInit, dend) \ 86400) Mod 365) & " days, "
sTime = sTime & Str((DateDiff("s", dInit, dend) \ 3600) Mod 24) & " hours, "
sTime = sTime & Str((DateDiff("s", dInit, dend) \ 60) Mod 60) & " minutes, "
sTime = sTime & Str(DateDiff("s", dInit, dend) Mod 60) & " seconds."
End Function


What it does is calculate the difference in seconds and adjust to days, hours ...

example: Imagine that in a TextBox (Text1) have a date in this format "25/07/2007 15:00:00" and in another (Text2) following "26/07/2007 17:25:32"
If you make a function call like this:
Variable = sTime(Text1, Text2)
will return the string "1 day, 2 hours, 25 minutes, 32 seconds."

But I want the range tell me the months, weeks and days.
For example from 01/03/2013 to 10/04/2013 and tell me 1 MONTH, 1 WEEK and 3 DAYS .

Could it be done?

Viewing all articles
Browse latest Browse all 2703

Trending Articles