January 14, 2003 at 8:21 am
Hi all,
I have an application that is inserting a date in datetime format to the database as 1/14/2003. If the customer wants to have a range like 1/14/2003 - 5/14/2003 how would i set this up in the database? Do i have to create another table or can this be added to the same table? Also what datatype should i use?
Any help would be appreciated.
January 14, 2003 at 8:27 am
You could add another datetime field to your existing table for the end date of the range and put the start date of the range into the existing datetime column.
Regards,
Andy Jones
.
January 14, 2003 at 8:37 am
Only drawback to that is i want to pre-plan events. So if an event is 3 months from now i want to be able to add that and it lists by date decending.
January 14, 2003 at 8:42 am
If you want to have more than one date range linked to a single record, you can store the range in a separate table with a FK referencing the original table.
Getting the results is a straightforward left outer join with an order by clause.
January 14, 2003 at 2:36 pm
Can you post what the expected results would be for the data. I see you would add an end date range as described by Andy. As for your statement as he stated the losest value will be your start date so listing by date descending should be as simple as selecting and order by start date. However I am confused by your statement and think maybe you need to know if a date is within the range in the table. If so then you do a query like so.
SELECT * FROM tblX WHERE 'mydateval' BETWEEN StartDate AND EndDate
or similar type query. But if I am wrong can you please explain what you mean?
January 17, 2003 at 7:04 am
Well guys I got it working by writing a funcion that replaces the two dates entered into the two fileds and formats them to look like this date1 - date2..
Thanks to all.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply