Date Relative String

  • Thread starter Thread starter kymbo
  • Start date Start date
K

kymbo

Hi all,

I am after a way of returning a string to indicate date/time span.

For example,
If I was to pass a date 10 days from now it might return "next week",
If I was to pass a date 7 days ago it might return "last week",
If I was to pass a date 30 days from now it might return "next month"
If I was to pass a date of now+1 it would return "tomorrow"
If I was to pass a time of two hours from now it would return "2
hours from now"

Hope you get the idea. The same sort of thing happens in Outlook if
you group by date.

Just wondering if anyone knows an easy way of doing this. I could code
this up myself but lots of applications provide this facility so I
figure it must be out there somewhere. Does anyone know how to do
this?

Cheers,
Kym
 
The .net framework doesn't provide something like that (maybe you can find
free code in the internet).
But it shouldn't be so complicated.
 
I agree it shouldn't be too hard to put something like this together --
I just thought it might exist somewhere already...

Oh well, at least I can get my hands dirty with a bit of code :)

*tap* *tap* *tap*
 
The problem is that every application has its own needs. if we have date
31-12 and you want to get the string of next day. this is next month, next
week, next year or tomorrow? is 23:00 o'clock +1 hour "in one hour" or
tomorrow?
 
Back
Top