Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2009
    Posts
    28

    Unanswered: decade expression in informix query

    Dear
    Please I am trying to write a query that would be executed every day 10, 20 and 30 of every month but I am facing problem to write it. The query would look like this
    select amount,tyep from storedata where day="10/02/2012" for day 10 for example but i would not be free to go an change the day every month.
    Thanks

  2. #2
    Join Date
    Sep 2011
    Location
    Pont l'Abbé, Brittany, France
    Posts
    381
    Provided Answers: 1
    Hi,

    if you run the query on days 10, 20 and 30, just use the "today" keyword in your sql statement:

    Code:
    select amount,tyep from storedata where day = today
    and that's it!

    Eric

  3. #3
    Join Date
    Dec 2009
    Posts
    28
    Hi Eric
    Thanks for your reply but please if i want at day 10 of the current month to retrieve rows from table without openning a query and modifying day every time what should I proceed?
    Thanks

  4. #4
    Join Date
    Sep 2011
    Location
    Pont l'Abbé, Brittany, France
    Posts
    381
    Provided Answers: 1
    With the code I wrote for you, the query will take the system date, so if you run the sql script on day 10, it will where day = <today which is day 10>

    if you run it on day 20, it will take day 20.

    My understand is that this is what you want, isn't it?

  5. #5
    Join Date
    Dec 2009
    Posts
    28

    next

    Hi Sir
    Thanks I am going to implement this today statement in my query but what happen if the day 10 or 20 is not working day like saturday or sunday? Is it possible to add a feature that would check the day of the week to see if it is not saturday and sunday?
    Thanks I would right back to you
    Regards

  6. #6
    Join Date
    Sep 2011
    Location
    Pont l'Abbé, Brittany, France
    Posts
    381
    Provided Answers: 1
    This code will do the same and only select data for
    weekdays 1 to 5, meaning from monday to Friday

    Code:
    select amount,type from storedata where day = today
    and weekday(day) in ( 1,2,3,4,5)
    is this what you want.

Posting Permissions

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