Can you select future dates that do not yet exist in table?

This is a discussion on Can you select future dates that do not yet exist in table? within the MySQL Database forums, part of the Database Forums category; I have a program I'm working on that does has a graph to show what is the future estimate ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-16-2007
sparky
 
Posts: n/a
Default Can you select future dates that do not yet exist in table?

I have a program I'm working on that does has a graph to show what is
the future estimate of production of eggs from a bunch of different
farmers.

The table I have is this:
CREATE TABLE `henbatch` (
`henBatch_ID` int(11) NOT NULL auto_increment,
`Barn_ID` int(11) NOT NULL,
`Quantity` int(11) NOT NULL,
`StartDate` date default NULL,
`SlaughteredDate` date default NULL,
`StartDateSet` tinyint(1) default NULL,
`Received` tinyint(1) NOT NULL,
PRIMARY KEY (`henBatch_ID`)
)

StartdateSet is there because of something that I was thinking should
work, but don't know anymore if it will.

What I need to do is to select from this table for future entries that
might not yet have been entered. I need to group weekly or maybe
monthly the estimated sum of hens that are still in production. In
another table the barn has the lifetime for the batch of hens. Can
someone give me a suggestion on how to do this? Can this be done just
with a select statement from this table? Any questions, please ask.
- It's hard to explain.

Thanks

Reply With Quote
  #2 (permalink)  
Old 10-17-2007
Jerry Stuckle
 
Posts: n/a
Default Re: Can you select future dates that do not yet exist in table?

sparky wrote:
> I have a program I'm working on that does has a graph to show what is
> the future estimate of production of eggs from a bunch of different
> farmers.
>
> The table I have is this:
> CREATE TABLE `henbatch` (
> `henBatch_ID` int(11) NOT NULL auto_increment,
> `Barn_ID` int(11) NOT NULL,
> `Quantity` int(11) NOT NULL,
> `StartDate` date default NULL,
> `SlaughteredDate` date default NULL,
> `StartDateSet` tinyint(1) default NULL,
> `Received` tinyint(1) NOT NULL,
> PRIMARY KEY (`henBatch_ID`)
> )
>
> StartdateSet is there because of something that I was thinking should
> work, but don't know anymore if it will.
>
> What I need to do is to select from this table for future entries that
> might not yet have been entered. I need to group weekly or maybe
> monthly the estimated sum of hens that are still in production. In
> another table the barn has the lifetime for the batch of hens. Can
> someone give me a suggestion on how to do this? Can this be done just
> with a select statement from this table? Any questions, please ask.
> - It's hard to explain.
>
> Thanks
>
>


If they haven't been entered, how can you select them? SELECT only
returns what's in the database.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #3 (permalink)  
Old 10-17-2007
ZeldorBlat
 
Posts: n/a
Default Re: Can you select future dates that do not yet exist in table?

On Oct 16, 9:17 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> sparky wrote:
> > I have a program I'm working on that does has a graph to show what is
> > the future estimate of production of eggs from a bunch of different
> > farmers.

>
> > The table I have is this:
> > CREATE TABLE `henbatch` (
> > `henBatch_ID` int(11) NOT NULL auto_increment,
> > `Barn_ID` int(11) NOT NULL,
> > `Quantity` int(11) NOT NULL,
> > `StartDate` date default NULL,
> > `SlaughteredDate` date default NULL,
> > `StartDateSet` tinyint(1) default NULL,
> > `Received` tinyint(1) NOT NULL,
> > PRIMARY KEY (`henBatch_ID`)
> > )

>
> > StartdateSet is there because of something that I was thinking should
> > work, but don't know anymore if it will.

>
> > What I need to do is to select from this table for future entries that
> > might not yet have been entered. I need to group weekly or maybe
> > monthly the estimated sum of hens that are still in production. In
> > another table the barn has the lifetime for the batch of hens. Can
> > someone give me a suggestion on how to do this? Can this be done just
> > with a select statement from this table? Any questions, please ask.
> > - It's hard to explain.

>
> > Thanks

>
> If they haven't been entered, how can you select them? SELECT only
> returns what's in the database.
>
> --


Right -- don't underestimate the usefulness of a "calendar" table.
Just create a table that has every date in it for a reasonable range.
You can then start with this table, outer join your other tables, and
get a row for every date -- even if there's nothing in your "henbatch"
table.

You may find it to be useful for other things, too -- in our
application we use it to keep track of business days and holidays so
we know when to skip processing for a day.

Reply With Quote
  #4 (permalink)  
Old 10-17-2007
strawberry
 
Posts: n/a
Default Re: Can you select future dates that do not yet exist in table?

On 17 Oct, 04:18, ZeldorBlat <zeldorb...@gmail.com> wrote:
> On Oct 16, 9:17 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
>
>
> > sparky wrote:
> > > I have a program I'm working on that does has a graph to show what is
> > > the future estimate of production of eggs from a bunch of different
> > > farmers.

>
> > > The table I have is this:
> > > CREATE TABLE `henbatch` (
> > > `henBatch_ID` int(11) NOT NULL auto_increment,
> > > `Barn_ID` int(11) NOT NULL,
> > > `Quantity` int(11) NOT NULL,
> > > `StartDate` date default NULL,
> > > `SlaughteredDate` date default NULL,
> > > `StartDateSet` tinyint(1) default NULL,
> > > `Received` tinyint(1) NOT NULL,
> > > PRIMARY KEY (`henBatch_ID`)
> > > )

>
> > > StartdateSet is there because of something that I was thinking should
> > > work, but don't know anymore if it will.

>
> > > What I need to do is to select from this table for future entries that
> > > might not yet have been entered. I need to group weekly or maybe
> > > monthly the estimated sum of hens that are still in production. In
> > > another table the barn has the lifetime for the batch of hens. Can
> > > someone give me a suggestion on how to do this? Can this be done just
> > > with a select statement from this table? Any questions, please ask.
> > > - It's hard to explain.

>
> > > Thanks

>
> > If they haven't been entered, how can you select them? SELECT only
> > returns what's in the database.

>
> > --

>
> Right -- don't underestimate the usefulness of a "calendar" table.
> Just create a table that has every date in it for a reasonable range.
> You can then start with this table, outer join your other tables, and
> get a row for every date -- even if there's nothing in your "henbatch"
> table.
>
> You may find it to be useful for other things, too -- in our
> application we use it to keep track of business days and holidays so
> we know when to skip processing for a day.


Just add each date one at a time for the next millenia.... or follow
this thread... http://datacharmer.blogspot.com/2006_06_01_archive.html

Reply With Quote
  #5 (permalink)  
Old 10-17-2007
sparky
 
Posts: n/a
Default Re: Can you select future dates that do not yet exist in table?

On Oct 17, 1:00 am, strawberry <zac.ca...@gmail.com> wrote:
> On 17 Oct, 04:18, ZeldorBlat <zeldorb...@gmail.com> wrote:
>
>
>
> > On Oct 16, 9:17 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:

>
> > > sparky wrote:
> > > > I have a program I'm working on that does has a graph to show what is
> > > > the future estimate of production of eggs from a bunch of different
> > > > farmers.

>
> > > > The table I have is this:
> > > > CREATE TABLE `henbatch` (
> > > > `henBatch_ID` int(11) NOT NULL auto_increment,
> > > > `Barn_ID` int(11) NOT NULL,
> > > > `Quantity` int(11) NOT NULL,
> > > > `StartDate` date default NULL,
> > > > `SlaughteredDate` date default NULL,
> > > > `StartDateSet` tinyint(1) default NULL,
> > > > `Received` tinyint(1) NOT NULL,
> > > > PRIMARY KEY (`henBatch_ID`)
> > > > )

>
> > > > StartdateSet is there because of something that I was thinking should
> > > > work, but don't know anymore if it will.

>
> > > > What I need to do is to select from this table for future entries that
> > > > might not yet have been entered. I need to group weekly or maybe
> > > > monthly the estimated sum of hens that are still in production. In
> > > > another table the barn has the lifetime for the batch of hens. Can
> > > > someone give me a suggestion on how to do this? Can this be done just
> > > > with a select statement from this table? Any questions, please ask.
> > > > - It's hard to explain.

>
> > > > Thanks

>
> > > If they haven't been entered, how can you select them? SELECT only
> > > returns what's in the database.

>
> > > --

>
> > Right -- don't underestimate the usefulness of a "calendar" table.
> > Just create a table that has every date in it for a reasonable range.
> > You can then start with this table, outer join your other tables, and
> > get a row for every date -- even if there's nothing in your "henbatch"
> > table.

>
> > You may find it to be useful for other things, too -- in our
> > application we use it to keep track of business days and holidays so
> > we know when to skip processing for a day.

>
> Just add each date one at a time for the next millenia.... or follow
> this thread...http://datacharmer.blogspot.com/2006_06_01_archive.html


Thank you strawberry and ZeldorBlat. I realized last night I would
probably have to create the dates table. I now have that table, but
I'm not quite sure yet how to query these tables with a group by so
that it will give me the proper result.

Say I have daily entries in the dates table, and I want to get a
forcast for the next 2 years, grouped by month, how do I prevent one
hen batch from summing up multiple times per month? Or should I add
another column to the dates table to specify that these are weekly,
daily and monthly dates?

Thanks


Reply With Quote
Reply


Thread Tools
Display Modes

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

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



All times are GMT +1. The time now is 05:14 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0