473,656 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Relative String

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

Apr 24 '06 #1
3 1151
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.

"kymbo" <kp*********@gm ail.com> schrieb im Newsbeitrag
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
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

Apr 24 '06 #2
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*

Apr 25 '06 #3
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?

"kymbo" <kp*********@gm ail.com> schrieb im Newsbeitrag
news:11******** *************@y 43g2000cwc.goog legroups.com...
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*

Apr 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
9286
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and three dropdow boxes for hours, minutes, and AM/PM. All of these need to be considered together and converted to one Unix Timestamp and then inserted to the MYSQL date field. The type of field is INT (11) so that I can instead of the standard...
8
9436
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $ Last-Modified: $Date: 2003/10/28 19:48:44 $ Author: A.M. Kuchling <amk@amk.ca> Status: Draft Type: Standards Track
2
5210
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much appreciated. TIA
3
1302
by: Bob Stearns | last post by:
I have a column which is the relative day number to give a treatment on. For a particular patient, where I know the starting date, how do I show the actual date for each relative day? the best I can see is: SELECT ..., DATE(DAYS(start_date)+relative_days-1), ... Is that the best/preferred method for this problem?
6
11760
by: openleren | last post by:
Hi all, how can I use a relative path in my web.config file for an Access db?: Instead of using <configuration> <appSettings> <add key="conAccess" value="microsoft.jet.oledb.4.0;data source=c:/Inetpub/MyApp/data/database.mdb" /> ...
4
4138
by: Christie | last post by:
My app creates a rigistry entry of the date when it is installed, which is then used to determine when the demo expires...It is working fine but I would like to encrypt the date somehow...is there a relative easy way to do this, as different machines will have different date formats?? I am using Visual Studio 2005(VB.Net)
44
10182
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
15
4355
by: Steve | last post by:
Hi All, I have a registration code that currently has 4 bytes that are unused. I'd like to store a future date in those 4 bytes. Is there a way to convert a date to a 4 byte string? When I do something like this, string stringDate = DateTime.Parse("1/15/2210").ToBinary().ToString("X");
1
3167
by: vp.softverm | last post by:
hi all . Am facing problem with the date picker. when i click on date picker in a popup window. the date table is opened in the middle of the pop up window. and it is unable to scroll with the pop up window .
0
8380
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.