Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Is possible make this query dates?

ostredeostrede Posts: 1Member
Hi, I have do a query VBNET with a date range. As follows:

[b]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[/b]

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)
[b]will return the string "1 day, 2 hours, 25 minutes, 32 seconds."[/b]

[b][color=Red]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 .[/color][/b]
[b]Could it be done?[/b]
Sign In or Register to comment.