General discussion

Locked

SQL on Date field

By Lord Foul ·
In my DB table i record peoples Names and the Dates and Times they perform Activities. I am trying to calculate the total hours of activities between two date periods for monthly reporting. the dates are saved as dd/mm/yy format. the structure of myquery is,
Select Sum(TotalHours)
From VolunteerHours
Where Date
Between 10/10/00 and 10/11/00;
and i receive a div by 0 error.
can anyone suggest how i can calculate totals using the date fields in an SQL query.
cheers,
ghost

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

SQL on Date field

by sl-campbell In reply to SQL on Date field

When you write it like thst, you are doing a division:
10/10/00 (10 divided by 10 divided by 0)

You need to do it like this:
Between #10/10/00# and #10/11/00#;

Collapse -

SQL on Date field

by Lord Foul In reply to SQL on Date field

Thanks for your reply. Enclosing the dates as you have suggested has corrected the div by 0 error.
I am using two dates #10/11/00# and #13/10/00# to test the sum of the total hours, this query result gives me 256 however on review of the data the correct result is 50. any ideas!
ghost@netlink.com.au

Collapse -

SQL on Date field

by Lord Foul In reply to SQL on Date field

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums