Consulting

Results 1 to 7 of 7

Thread: Dates before 30 days

  1. #1

    Dates before 30 days

    Friends,

    I have this sql statement:

    SELECT TblAnalista.NomeDoAnalista, TblEmpresa.NomeDaEmpresa, TblProduto.NomeDoProduto, TblPassosStatus.Passo, Nz([DataReprogramada],[DataProgramada]) AS DataDue, TblPassosStatus.C
    FROM ((TblAnalista LEFT JOIN TblEmpresa ON TblAnalista.CodAnalista=TblEmpresa.CodAnalista) LEFT JOIN TblProduto ON TblEmpresa.CodEmpresa=TblProduto.CodEmpresa) LEFT JOIN TblPassosStatus ON TblProduto.CodProduto=TblPassosStatus.CodProduto
    WHERE (((Nz([DataReprogramada],[DataProgramada]))<Date()) AND ((TblPassosStatus.DataRealizada) Is Null) AND ((TblProduto.[Ativado])=Yes))
    ORDER BY Nz([DataProgramada],[DataReprogramada]);


    WHERE I have provided all dates less than today.
    For example, How do I select only dates overdue for more than
    30 days, ie, all the dates before March 20?

    Thank you.

  2. #2
    VBAX Tutor mohanvijay's Avatar
    Joined
    Aug 2010
    Location
    MADURAI
    Posts
    268
    Location
    Try DateDiff Function

  3. #3
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    where table.datefield < today()-30
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  4. #4
    mohanvijay jand BrianMH, thanks for responding.
    Sorry, I drew up wrong, I'm trying two criteria.
    I'm trying to dates before today between 15 and 30 days.
    For example, dates from March 20 until April 5, ie 30 days before until 15 days before today.

    Thank you.

  5. #5
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    where (table.datefield < today() -15 and table.datefield > today()-30)
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  6. #6
    How do I put the sql, so I tried but did not work. Syntax error (missing operator).

    SELECT TblAnalista.NomeDoAnalista, TblEmpresa.NomeDaEmpresa, TblProduto.NomeDoProduto, TblPassosStatus.Passo, Nz([DataReprogramada],[DataProgramada]) AS DataDue, TblPassosStatus.C
    FROM ((TblAnalista LEFT JOIN TblEmpresa ON TblAnalista.CodAnalista=TblEmpresa.CodAnalista) LEFT JOIN TblProduto ON TblEmpresa.CodEmpresa=TblProduto.CodEmpresa) LEFT JOIN TblPassosStatus ON TblProduto.CodProduto=TblPassosStatus.CodProduto
    WHERE (((Nz([DataReprogramada],[DataProgramada]))<Date()-15 AND ((Nz([DataReprogramada],[DataProgramada])) > Date()-30) AND ((TblPassosStatus.DataRealizada) Is Null) AND ((TblProduto.[Ativado])=Yes))
    ORDER BY Nz([DataProgramada],[DataReprogramada]);

  7. #7
    BrianMH and mohanvijay, thank you for help. I got using Between.

    WHERE Nz ([DataReprogramada], [DataProgramada]) Between Date () - 30 And Date () - 15 AND TblPassosStatus.DataRealizada Is Null AND TblProduto. [Enabled] = Yes
    Again, thank you.

Posting Permissions

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