The Stoat
The Grim Squeaker
- Local time
- Today, 13:05
- Joined
- May 26, 2004
- Messages
- 239
Hi all,
Just to be clear i don't mean a Between statement
I've come up against a problem and i'm really not sure what the correct solution is.
I want to store the leave dates for staff. The most space efficient way seems to be just to store the start and end dates of the leave period.
It also makes it easy to validate.
However I need to report on leave taken on any given day, week, or month which means being able to extract the individual days between the two dates.
This is bl***y difficult/messy to do using the start date and end date format.
I can do it simply if i store all the individual days taken as leave but the amount of data stored would be huge.
I did find this on the net for an Oracle db but i can't quite get my head round it.
Apparently rownum is a virtual field that oracle creates for all tables that incrementally counts the number of rows in the table. I'm not sure how that helps here but...
....my best approximation for access is where rownum should be an integer that increments by 1 for each pass. So i could put this in a field in a query
And then use it like this - in the same query
Trouble is it doesn't work. It keeps asking me for rownum
Any ideas how i might do this?
Thanks
TS


I've come up against a problem and i'm really not sure what the correct solution is.

I want to store the leave dates for staff. The most space efficient way seems to be just to store the start and end dates of the leave period.
It also makes it easy to validate.
However I need to report on leave taken on any given day, week, or month which means being able to extract the individual days between the two dates.
This is bl***y difficult/messy to do using the start date and end date format.
I can do it simply if i store all the individual days taken as leave but the amount of data stored would be huge.
I did find this on the net for an Oracle db but i can't quite get my head round it.
Apparently rownum is a virtual field that oracle creates for all tables that incrementally counts the number of rows in the table. I'm not sure how that helps here but...
Code:
SELECT TO_DATE('12/01/2003', 'MM/DD/YYYY') - 1 + rownum AS d
FROM all_objects
WHERE TO_DATE('12/01/2003', 'MM/DD/YYYY') - 1 + rownum <= TO_DATE('12/05/2003', 'MM/DD/YYYY')
....my best approximation for access is where rownum should be an integer that increments by 1 for each pass. So i could put this in a field in a query
Code:
rownum: (Select Count (*) FROM [TBL_LEAVE] as Temp WHERE [Temp].[LEAVE_ID] < [TBL_LEAVE].[LEAVE_ID])+1
And then use it like this - in the same query
Code:
SELECT dateadd("d" ,-1 ,[start_date]) + rownum AS d
FROM TBL_LEAVE
WHERE dateadd("d", -1 ,[start_date]) + rownum <= [end_date]
Trouble is it doesn't work. It keeps asking me for rownum


Any ideas how i might do this?
Thanks
TS
Last edited: