User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 428,634 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,954 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 3254 | Replies: 1
Reply
Join Date: Sep 2004
Posts: 1
Reputation: cwobie is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cwobie cwobie is offline Offline
Newbie Poster

Comparing and sorting of Dates.

  #1  
Sep 15th, 2004
Good day.
I am busy writing a small console program and need help with the following:

- I need to be able to allow the user to enter a start date and end date and display data with dates which falls wihin this range.

- Once I have this data, I need to be able to sort the data by date.

I will be ever grateful if anyone can give me and example of how to do this as I am new to c++.
Thanks in advance.

Regards,
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2004
Posts: 3,655
Reputation: Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light 
Rep Power: 17
Solved Threads: 145
Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Comparing and sorting of Dates.

  #2  
Sep 15th, 2004
You may want to use a struct tm to hold integer values for the month, day, and year that the user enters. But keep in mind that this structure normally has the month from 0-11 and the year is a two-digit value based on the year 1900 (that is, 2004 is represented with the value 104). Using the struct tm properly lets you use other time-manipulation functions.

You could also make your own struct and keep dates "normal", or just use the struct tm with "normal" values. Either way, for the sorting would then recommend qsort (assuming C). What you would need to do is make your own comparison function.

Well, I see I'm already assuming too much about how you are defining records, the language you are using, and other such things. Do you have a start that you can show?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 12:53 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC