Results 1 to 7 of 7

Thread: Date sequence

  1. #1
    Join Date
    Jun 2006
    Posts
    2

    Unanswered: Date sequence

    How can i generate a list of dates between a begin and end date and add the list to a table?

  2. #2
    Join Date
    Jun 2004
    Location
    Terrapin Nation
    Posts
    205
    Quote Originally Posted by peterjackson
    How can i generate a list of dates between a begin and end date and add the list to a table?






    An easy way would be to create the list in Excel then paste them into your table. If you want to do this more than one time you should be a bit more specific with what you are trying to do.

  3. #3
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    Could somebody please explain the relevance of Excel to an SQL query?

    The answer is simple.

    select
    columns
    into
    table

    from
    tableA
    where
    @dateValue between a and b

    I cannot remember the specific Access syntax for a multi-row insert statement, so the top section of the expression may need refining.

    Thank You.
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Pete

    Love your films

    This is where a tally table is jolly useful. A SQL Server example is here:
    http://sqljunkies.com/WebLog/amachan...bersTable.aspx
    Obviously you would need to adapt.

    Code might be (air code - not spot on and just creates the values - doesn't insert):
    Code:
    SELECT DATEADD("d", MyNumber, Forms!MyForm!BeginDate) AS MyNewDates
    FROM MyNumbersTable
    WHERE MyNumber BETWEEN 0 AND DATEDIFF("d", Forms!MyForm!BeginDate, Forms!MyForm!EndDate)
    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by r123456
    The answer is simple.
    It is that simple if the dates exist. The questioner asked for the dates to be generated. I took that to mean you have two dates only. Correct me if I have misread.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Jun 2004
    Location
    Terrapin Nation
    Posts
    205
    What do you mena by "Could somebody please explain the relevance of Excel to an SQL query"?

  7. #7
    Join Date
    Jun 2006
    Posts
    2
    yes i only have the begin date and end date so i need do generate those in between

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •