home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2759
Discussions: 188,385, Posts: 2,243,516, Members: 232,615
Old February 1st, 2003, 10:03 PM   Digg it!   #1 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
SQL to return date range

I thought I knew an easy way to do this, but perhaps in the past used stored proc, or other object to accomplish...

How does one display all days from a given date range? As in:

tbl1
----
id
date

for example purposes, tbl1 is empty, 0 rows.

SELECT id FROM tbl1 WHERE date BETWEEN
"2003-2-01" and "2003-2-28";

And get 28 rows, with id = NULL.

OR if tbl1, has rows in date range, return that id, rest NULLs.

Seems silly to create:
tbl2
----
id = NULL
date = all dates for a year???

Then outer join to tbl1...

qball is offline   Reply With Quote
Old February 9th, 2003, 08:24 AM     #2 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 21,023
Hmm not sure if it would be possible with out a cursor...

Cursor would be fairly easy with a loop, but not quite as simple as a single statement.


Hmmm.. you used double quotes for those dates.. this isn't access is it?!

If so disregard the cursor, you're probably going to end up writing VBA or something


Last edited by vass0922 : February 9th, 2003 at 08:27 AM.
vass0922 is online now   Reply With Quote
Old February 9th, 2003, 03:02 PM     #3 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
I guess I'd say stored proc. #Temporary Table. Loop to insert dates in temp table. Use left join. Show all records from temp table that you inserted from date range and matching records from table with data.

Creosote is offline   Reply With Quote
Old February 9th, 2003, 11:49 PM     #4 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
vass0922,

not access, any real DBMS!

as stated, stored proc, with cursor to find data that does exist, fill in empty dates, created from date range request....

or 'object', access has these, as most client/server apps, also.
qball is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2897)
CPU wont boot (7)
3-days in and no threads about Gaza (160)
I think I just killed my computer w.. (24)
hp compaq nc6000 problems (139)
Upgrading RAM (5)
Folderchat Weekday thread (442)
Antec 300 bulk purchase? (11)
Worth the upgrade?? (15)
Recent Discussions
New Build ( Finally ) (3)
CPU wont boot (7)
Problem With LightScribe DVD Dr.. (0)
GLaDOS is up. (3)
HP notebook reinstall Vista NO .. (5)
Building a gaming computer advi.. (4)
hp compaq nc6000 problems (139)
Folderchat Weekday thread (442)
Creative T-3000 Subwoofer (3)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 11:07 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28