php-windows Digest 4 Jul 2012 16:40:58 -0000 Issue 4055

Topics (messages 30919 through 30925):

Re: Date Problem
        30919 by: Toby Hart Dyke
        30920 by: Jacob Kruger
        30921 by: Vinay Kannan
        30922 by: Jacob Kruger
        30923 by: Huiberts, Pieter J.
        30924 by: John Harris

Data mining scripts?
        30925 by: Jacob Kruger

Administrivia:

To subscribe to the digest, e-mail:
        php-windows-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-windows-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-wind...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
The date_add() function is your friend here. You will need to define what
happens when the start date is something like Nov 30th. When is the first
service due after that? If you use date_add() to add three months, it will
return March 1st (in a non-leap year).

Your first step should be to define the business rules - what happens when a
date doesn't exist (like February 30th)? Is it OK if the returned date is on
a weekend? Or a holiday?

  Toby


> -----Original Message-----
> From: Vinay Kannan [mailto:viny...@gmail.com]
> Sent: Thursday, June 21, 2012 2:27 AM
> To: php-wind...@lists.php.net; phpexpe...@yahoogroups.com; php mysql
> Subject: [PHP-WIN] Date Problem
> 
> Hey Guys,
> 
> I am working on a project for a client who is a retailer of inverters and
> batteries, and currently the system records the salesdetails including the
> warranty expiry date which is always a year(12 months).
> 
> But he wishes to provide support and service every 3 months and that seems
> to be the beginning of my problems :D
> 
> if the warranty on billno ='100' expires on 2012-09-27, the system has to
show
> him this billno 4 times as a service due.
> Eg: a product was sold and a bill generated on 2011-9-27, the warranty on
the
> products expires on 2012-9-27, so the system has to show the first service
> due on 2011-12-27, then one on 2012-3-27, then on 2012-6-27.
> 
> How do i go about it?
> 
> Any help is much appreciated.
> 
> Thanks,


--- End Message ---
--- Begin Message --- While this might not be perfect/exact information, here's a link to the w3schools.com date/time functions reference page, and, off-hand, you could convert a date string into a timestamp, and then just add, or subtract the relevant timestamp amount from it, using the sort of formula that a timestamp is measured in seconds, and thus, for example, 1 day = 60 * 60 * 24 seconds to be added or subtracted from the result of the mktime, or strtotime functions executed on the date formatted string, if that's what you have to work with/on:
http://www.w3schools.com/php/php_ref_date.asp

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message ----- From: "Vinay Kannan" <viny...@gmail.com> To: <php-wind...@lists.php.net>; <phpexpe...@yahoogroups.com>; "php mysql" <php_mysql_usergr...@yahoogroups.com>
Sent: Thursday, June 21, 2012 8:27 AM
Subject: [PHP-WIN] Date Problem


Hey Guys,

I am working on a project for a client who is a retailer of inverters and
batteries, and currently the system records the salesdetails including the
warranty expiry date which is always a year(12 months).

But he wishes to provide support and service every 3 months and that seems
to be the beginning of my problems :D

if the warranty on billno ='100' expires on 2012-09-27, the system has to
show him this billno 4 times as a service due.
Eg: a product was sold and a bill generated on 2011-9-27, the warranty on
the products expires on 2012-9-27, so the system has to show the first
service due on 2011-12-27, then one on 2012-3-27, then on 2012-6-27.

How do i go about it?

Any help is much appreciated.

Thanks,



--- End Message ---
--- Begin Message ---
Hi Toby, Jacob

Thank You Toby and Jacob for your help! I figured my way out and was able
to fix the issue, what i did was, i built another table called servicesdue
and updated the columns service1,service2,service3, used DATE_ADD to
populate these 3 date fields.

I figured the best way to go forward to have the new table with the
saledate and the service due dates, this way even while the system is
working, the calls to the DB and back to the page will be very less
expensive on the CPU, since PHP doesn't have to calculate a lot of things
and doesn't have to browse through the entire DB with these calculated
values.

This way the draw back is that there might be more memory usage since there
is a new table with data in it, but then the script only has to go through
the page once every day.

Correct me if my way of thinking on this was incorrect?

Thanks,
Vinay

On Thu, Jun 21, 2012 at 4:46 PM, Toby Hart Dyke <t...@hartdyke.com> wrote:

> The date_add() function is your friend here. You will need to define what
> happens when the start date is something like Nov 30th. When is the first
> service due after that? If you use date_add() to add three months, it will
> return March 1st (in a non-leap year).
>
> Your first step should be to define the business rules - what happens when
> a
> date doesn't exist (like February 30th)? Is it OK if the returned date is
> on
> a weekend? Or a holiday?
>
>  Toby
>
>
> > -----Original Message-----
> > From: Vinay Kannan [mailto:viny...@gmail.com]
> > Sent: Thursday, June 21, 2012 2:27 AM
> > To: php-wind...@lists.php.net; phpexpe...@yahoogroups.com; php mysql
> > Subject: [PHP-WIN] Date Problem
> >
> > Hey Guys,
> >
> > I am working on a project for a client who is a retailer of inverters and
> > batteries, and currently the system records the salesdetails including
> the
> > warranty expiry date which is always a year(12 months).
> >
> > But he wishes to provide support and service every 3 months and that
> seems
> > to be the beginning of my problems :D
> >
> > if the warranty on billno ='100' expires on 2012-09-27, the system has to
> show
> > him this billno 4 times as a service due.
> > Eg: a product was sold and a bill generated on 2011-9-27, the warranty on
> the
> > products expires on 2012-9-27, so the system has to show the first
> service
> > due on 2011-12-27, then one on 2012-3-27, then on 2012-6-27.
> >
> > How do i go about it?
> >
> > Any help is much appreciated.
> >
> > Thanks,
>
>

--- End Message ---
--- Begin Message ---
I wouldn't really be the perfect person to answer this question, but does sound 
about right to me...:)

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

  ----- Original Message ----- 
  From: Vinay Kannan 
  To: Toby Hart Dyke ; ja...@blindza.co.za 
  Cc: php-wind...@lists.php.net ; phpexpe...@yahoogroups.com ; php mysql 
  Sent: Thursday, June 21, 2012 1:46 PM
  Subject: Re: [PHP-WIN] Date Problem


  Hi Toby, Jacob


  Thank You Toby and Jacob for your help! I figured my way out and was able to 
fix the issue, what i did was, i built another table called servicesdue and 
updated the columns service1,service2,service3, used DATE_ADD to populate these 
3 date fields.


  I figured the best way to go forward to have the new table with the saledate 
and the service due dates, this way even while the system is working, the calls 
to the DB and back to the page will be very less expensive on the CPU, since 
PHP doesn't have to calculate a lot of things and doesn't have to browse 
through the entire DB with these calculated values.


  This way the draw back is that there might be more memory usage since there 
is a new table with data in it, but then the script only has to go through the 
page once every day.


  Correct me if my way of thinking on this was incorrect?


  Thanks,
  Vinay


  On Thu, Jun 21, 2012 at 4:46 PM, Toby Hart Dyke <t...@hartdyke.com> wrote:

    The date_add() function is your friend here. You will need to define what
    happens when the start date is something like Nov 30th. When is the first
    service due after that? If you use date_add() to add three months, it will
    return March 1st (in a non-leap year).

    Your first step should be to define the business rules - what happens when a
    date doesn't exist (like February 30th)? Is it OK if the returned date is on
    a weekend? Or a holiday?

     Toby



    > -----Original Message-----
    > From: Vinay Kannan [mailto:viny...@gmail.com]
    > Sent: Thursday, June 21, 2012 2:27 AM
    > To: php-wind...@lists.php.net; phpexpe...@yahoogroups.com; php mysql
    > Subject: [PHP-WIN] Date Problem
    >
    > Hey Guys,
    >
    > I am working on a project for a client who is a retailer of inverters and
    > batteries, and currently the system records the salesdetails including the
    > warranty expiry date which is always a year(12 months).
    >
    > But he wishes to provide support and service every 3 months and that seems
    > to be the beginning of my problems :D
    >
    > if the warranty on billno ='100' expires on 2012-09-27, the system has to
    show
    > him this billno 4 times as a service due.
    > Eg: a product was sold and a bill generated on 2011-9-27, the warranty on
    the
    > products expires on 2012-9-27, so the system has to show the first service
    > due on 2011-12-27, then one on 2012-3-27, then on 2012-6-27.
    >
    > How do i go about it?
    >
    > Any help is much appreciated.
    >
    > Thanks,




--- End Message ---
--- Begin Message ---
Sorry gentlemen, quick question how do I unsubscribe from this list?

Pieter J.D. Huiberts M.S. | SAIC
Sr. Software/Database Engineer | Life Sciences Operation | Health
Solutions Business Unit
phone: 240-529-0411 | mobile: 240-357-5885
pieter.j.huibe...@saic.com | www.saic.com


-----Original Message-----
From: php-windows-return-30922-pieter.j.huiberts=saic....@lists.php.net
[mailto:php-windows-return-30922-pieter.j.huiberts=saic....@lists.php.ne
t] On Behalf Of Jacob Kruger
Sent: Thursday, June 21, 2012 8:36 AM
To: php-wind...@lists.php.net
Subject: Re: [PHP-WIN] Date Problem

I wouldn't really be the perfect person to answer this question, but
does sound about right to me...:)

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

  ----- Original Message ----- 
  From: Vinay Kannan 
  To: Toby Hart Dyke ; ja...@blindza.co.za 
  Cc: php-wind...@lists.php.net ; phpexpe...@yahoogroups.com ; php mysql

  Sent: Thursday, June 21, 2012 1:46 PM
  Subject: Re: [PHP-WIN] Date Problem


  Hi Toby, Jacob


  Thank You Toby and Jacob for your help! I figured my way out and was
able to fix the issue, what i did was, i built another table called
servicesdue and updated the columns service1,service2,service3, used
DATE_ADD to populate these 3 date fields.


  I figured the best way to go forward to have the new table with the
saledate and the service due dates, this way even while the system is
working, the calls to the DB and back to the page will be very less
expensive on the CPU, since PHP doesn't have to calculate a lot of
things and doesn't have to browse through the entire DB with these
calculated values.


  This way the draw back is that there might be more memory usage since
there is a new table with data in it, but then the script only has to go
through the page once every day.


  Correct me if my way of thinking on this was incorrect?


  Thanks,
  Vinay


  On Thu, Jun 21, 2012 at 4:46 PM, Toby Hart Dyke <t...@hartdyke.com>
wrote:

    The date_add() function is your friend here. You will need to define
what
    happens when the start date is something like Nov 30th. When is the
first
    service due after that? If you use date_add() to add three months,
it will
    return March 1st (in a non-leap year).

    Your first step should be to define the business rules - what
happens when a
    date doesn't exist (like February 30th)? Is it OK if the returned
date is on
    a weekend? Or a holiday?

     Toby



    > -----Original Message-----
    > From: Vinay Kannan [mailto:viny...@gmail.com]
    > Sent: Thursday, June 21, 2012 2:27 AM
    > To: php-wind...@lists.php.net; phpexpe...@yahoogroups.com; php
mysql
    > Subject: [PHP-WIN] Date Problem
    >
    > Hey Guys,
    >
    > I am working on a project for a client who is a retailer of
inverters and
    > batteries, and currently the system records the salesdetails
including the
    > warranty expiry date which is always a year(12 months).
    >
    > But he wishes to provide support and service every 3 months and
that seems
    > to be the beginning of my problems :D
    >
    > if the warranty on billno ='100' expires on 2012-09-27, the system
has to
    show
    > him this billno 4 times as a service due.
    > Eg: a product was sold and a bill generated on 2011-9-27, the
warranty on
    the
    > products expires on 2012-9-27, so the system has to show the first
service
    > due on 2011-12-27, then one on 2012-3-27, then on 2012-6-27.
    >
    > How do i go about it?
    >
    > Any help is much appreciated.
    >
    > Thanks,




--- End Message ---
--- Begin Message ---
On 21 Jun 2012 8:43, Huiberts, Pieter J. wrote

> Sorry gentlemen, quick question how do I unsubscribe from this list?
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Follow the information provided?

-John


--- End Message ---
--- Begin Message ---
Ok, have now got a copy of the PostGreSQL database/structures on my own, 
development machine, but would like to be able to populate it with data I can 
pull off live server, but, since although can access live database/server via 
PHP code, but not currently via PGAdmin app on machine, was just wondering if 
should sort of manually rewrite my own form of data mining scripts to do 
something like pull CSV versions of data off server, and then import them into 
local database instance, or are there already similar things out there?

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

--- End Message ---

Reply via email to