Date Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mtek

    #1

    Date Question

    Hi,

    We have a form where the user selects a date from a calendar, the date
    is in the format May 23, 2008.

    The date in the datebase is in the format 05212008.

    What we need to do is get the starting and ending date of the week for
    the date selected in the form: May 23, 2008, and then get the records
    from the database where the dates fall within that range.

    So, from that date / format: May 23, 2008, how can I find the
    starting and ending dates for the week the date falls in???

    I'm still searching...... .

    Thanks!

    John
  • Jerry Stuckle

    #2
    Re: Date Question

    Mtek wrote:
    Hi,
    >
    We have a form where the user selects a date from a calendar, the date
    is in the format May 23, 2008.
    >
    The date in the datebase is in the format 05212008.
    >
    What we need to do is get the starting and ending date of the week for
    the date selected in the form: May 23, 2008, and then get the records
    from the database where the dates fall within that range.
    >
    So, from that date / format: May 23, 2008, how can I find the
    starting and ending dates for the week the date falls in???
    >
    I'm still searching...... .
    >
    Thanks!
    >
    John
    John,

    Rather, you should put the date in the database as a DATE field (i.e.
    typically '2008-05-23'). Then use database functions to find the
    information.

    The way you're storing it will cause you all kinds of problems. For
    more information on the database end, see a newsgroup for your database
    (i.e. comp.databases. mysql for MySQL).

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

    Comment

    • Mtek

      #3
      Re: Date Question

      On May 27, 6:16 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
      Mtek wrote:
      Hi,
      >
      We have a form where the user selects a date from a calendar, the date
      is in the format May 23, 2008.
      >
      The date in the datebase is in the format 05212008.
      >
      What we need to do is get the starting and ending date of the week for
      the date selected in the form: May 23, 2008, and then get the records
      from the database where the dates fall within that range.
      >
      So, from that date / format:  May 23, 2008, how can I find the
      starting and ending dates for the week the date falls in???
      >
      I'm still searching...... .
      >
      Thanks!
      >
      John
      >
      John,
      >
      Rather, you should put the date in the database as a DATE field (i.e.
      typically '2008-05-23').  Then use database functions to find the
      information.
      >
      The way you're storing it will cause you all kinds of problems.  For
      more information on the database end, see a newsgroup for your database
      (i.e. comp.databases. mysql for MySQL).
      >
      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstuck...@attgl obal.net
      =============== ===- Hide quoted text -
      >
      - Show quoted text -

      Thanks for the suggestion..... .

      Comment

      • Lars Eighner

        #4
        Re: Date Question

        In our last episode,
        <9f271ce4-52ce-4273-9fef-2adb8b0349bc@x3 5g2000hsb.googl egroups.com>, the
        lovely and talented Mtek broadcast on comp.lang.php:
        Hi,
        We have a form where the user selects a date from a calendar, the date
        is in the format May 23, 2008.
        The date in the datebase is in the format 05212008.
        Really? I assume this is an example of the day two days before the one
        mentioned above --- and a really bad format for a database.
        What we need to do is get the starting and ending date of the week for
        the date selected in the form: May 23, 2008, and then get the records
        from the database where the dates fall within that range.

        This is a homework question we get quite a lot.
        So, from that date / format: May 23, 2008, how can I find the
        starting and ending dates for the week the date falls in???
        First, what day is the first day of the week?
        Let's say it is Foosday.

        Find the time for the next Foosday from your given date.

        The start of the week containing your date is one week before that
        and the end is one day before.
        I'm still searching...... .
        If this were a real problem in the field instead of homework, your troubles
        would only be starting. You'd like the database to do the work of picking
        the records for you. Lot's of luck with your database format.


        --
        Lars Eighner <http://larseighner.com/usenet@larseigh ner.com
        Countdown: 237 days to go.

        Comment

        • Paul Lautman

          #5
          Re: Date Question

          Jerry Stuckle wrote:
          Mtek wrote:
          >Hi,
          >>
          >We have a form where the user selects a date from a calendar, the
          >date is in the format May 23, 2008.
          >>
          >The date in the datebase is in the format 05212008.
          >>
          >What we need to do is get the starting and ending date of the week
          >for the date selected in the form: May 23, 2008, and then get the
          >records from the database where the dates fall within that range.
          >>
          >So, from that date / format: May 23, 2008, how can I find the
          >starting and ending dates for the week the date falls in???
          >>
          >I'm still searching...... .
          >>
          >Thanks!
          >>
          >John
          >
          John,
          >
          Rather, you should put the date in the database as a DATE field (i.e.
          typically '2008-05-23'). Then use database functions to find the
          information.
          >
          The way you're storing it will cause you all kinds of problems. For
          more information on the database end, see a newsgroup for your
          database (i.e. comp.databases. mysql for MySQL).
          He already did!

          To the OP please do NOT multi post. Cross post if you must, but do not multi
          post.



          Comment

          • Jerry Stuckle

            #6
            Re: Date Question

            Paul Lautman wrote:
            Jerry Stuckle wrote:
            >Mtek wrote:
            >>Hi,
            >>>
            >>We have a form where the user selects a date from a calendar, the
            >>date is in the format May 23, 2008.
            >>>
            >>The date in the datebase is in the format 05212008.
            >>>
            >>What we need to do is get the starting and ending date of the week
            >>for the date selected in the form: May 23, 2008, and then get the
            >>records from the database where the dates fall within that range.
            >>>
            >>So, from that date / format: May 23, 2008, how can I find the
            >>starting and ending dates for the week the date falls in???
            >>>
            >>I'm still searching...... .
            >>>
            >>Thanks!
            >>>
            >>John
            >John,
            >>
            >Rather, you should put the date in the database as a DATE field (i.e.
            >typically '2008-05-23'). Then use database functions to find the
            >information.
            >>
            >The way you're storing it will cause you all kinds of problems. For
            >more information on the database end, see a newsgroup for your
            >database (i.e. comp.databases. mysql for MySQL).
            >
            He already did!
            >
            To the OP please do NOT multi post. Cross post if you must, but do not multi
            post.

            >
            >
            Yep, he did - after I recommended he ask there. And he didn't
            intentionally multipost - I don't think he was aware he could do some of
            what he wanted in the database.

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

            Comment

            • Paul Lautman

              #7
              Re: Date Question

              Jerry Stuckle wrote:
              Paul Lautman wrote:
              >Jerry Stuckle wrote:
              >>Mtek wrote:
              >>>Hi,
              >>>>
              >>>We have a form where the user selects a date from a calendar, the
              >>>date is in the format May 23, 2008.
              >>>>
              >>>The date in the datebase is in the format 05212008.
              >>>>
              >>>What we need to do is get the starting and ending date of the week
              >>>for the date selected in the form: May 23, 2008, and then get the
              >>>records from the database where the dates fall within that range.
              >>>>
              >>>So, from that date / format: May 23, 2008, how can I find the
              >>>starting and ending dates for the week the date falls in???
              >>>>
              >>>I'm still searching...... .
              >>>>
              >>>Thanks!
              >>>>
              >>>John
              >>John,
              >>>
              >>Rather, you should put the date in the database as a DATE field
              >>(i.e. typically '2008-05-23'). Then use database functions to find
              >>the information.
              >>>
              >>The way you're storing it will cause you all kinds of problems. For
              >>more information on the database end, see a newsgroup for your
              >>database (i.e. comp.databases. mysql for MySQL).
              >>
              >He already did!
              >>
              >To the OP please do NOT multi post. Cross post if you must, but do
              >not multi post.
              >http://www.blakjak.demon.co.uk/mul_crss.htm
              >>
              >>
              >
              Yep, he did - after I recommended he ask there. And he didn't
              intentionally multipost - I don't think he was aware he could do some
              of what he wanted in the database.
              Bugger! I carefully looked at the times on the posts before posting that
              advice, but my maths failed me!

              To the OP, please accept my humble apologies.


              Comment

              Working...