Current Date Query

  • Hi Guys,

    I am kind of struggling to get the result for current date orders but I can get the query working for due date.

    "

    SalesOrder.DateEntered,

    SalesLine.OrderQuantity, (SalesLine.OrderQuantity*SalesLine.SellingPrice / SalesOrder.ExchangeRate) AS Value,

    (SalesLine.SellingPrice / SalesOrder.ExchangeRate) AS Price

    FROM Company INNER JOIN

    CustomerAccount ON Company.CompanyID = CustomerAccount.CompanyID INNER JOIN

    SalesOrder ON CustomerAccount.CustomerAccountID = SalesOrder.CustomerAccountID INNER JOIN

    SalesLine ON SalesOrder.SalesOrderID = SalesLine.SalesOrderID

    WHERE (SalesOrder.DateEntered = { fn CURDATE() })

    "

    Can please someone tell me where am I going wrong? Or how could I get the current date orders?

    Thanks,

  • What's the problem? Not returning the data you expect?

    Can you please post:

    - Table scripts

    - Sample data

    - Expected results?

    See http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/ for directions.

    -- Gianluca Sartori

  • current date = cast(getdate() as date)

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • spaghettidba (5/7/2015)


    What's the problem? Not returning the data you expect?

    Can you please post:

    - Table scripts

    - Sample data

    - Expected results?

    See http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/ for directions.

    it does not return any data on dateentered but it returns data on due date.

  • yusufm 48726 (5/7/2015)


    spaghettidba (5/7/2015)


    What's the problem? Not returning the data you expect?

    Can you please post:

    - Table scripts

    - Sample data

    - Expected results?

    See http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/ for directions.

    it does not return any data on dateentered but it returns data on due date.

    This is not enough for us to be able to help: we don't know how your database works and we cannot see your screen. Please follow the link posted by Gianluca and post again with clearer details.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Please don't cross post. It just fragments replies and makes it harder for you and the people trying to help.

    http://www.sqlservercentral.com/Forums/Topic1683510-169-1.aspx

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • where do you think I should post it? I posted in the newbie and they told me not to post it there. I check SQL Server 2012-T SQL and a query question. I thought I am at the right place for someone to help.

    If I knew where to post it then why would I waste your time and mine?

  • yusufm 48726 (5/7/2015)


    where do you think I should post it? I posted in the newbie and they told me not to post it there. I check SQL Server 2012-T SQL and a query question. I thought I am at the right place for someone to help.

    If I knew where to post it then why would I waste your time and mine?

    So you think it's fine to post the same question in more than one place, having different people respond to each?

    In my opinion, it's plain rude. What if someone answers one of the threads, while the other remains open? People may well spend time trying to help you in the open thread, long after it has been answered elsewhere. If that's not wasting time, I don't know what is.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • here is the thing Phil. I had no idea where I should post it and when someone else said you are in the wrong place then I decide to post it on a different forum.

    If you think newbies are wasting your time and then do something about it rather than complain.

    Could you please tell me where is the close tab or something so I could close one of them and you lots would stop complaining.

  • yusufm 48726 (5/7/2015)


    where do you think I should post it? I posted in the newbie and they told me not to post it there. I check SQL Server 2012-T SQL and a query question. I thought I am at the right place for someone to help.

    If I knew where to post it then why would I waste your time and mine?

    First, looking at your two threads, I only see Sean asking you not to cross post your questions. No one in the other thread said anything about cross posting. The problem with cross posting is just what Sean mentioned, you get fragmented answers and no one really knows if the question has been answered.

    Most people that are highly active on ssc monitor the Active Threads list, not individual forums. As such, most of us will see your post regardless of where it is posted, we would just like to see it posted once, and hopefully in the appropriate forum for the version of SQL Server you are using. If you post in a version agnostic forum, then it would help if you specify what version of SQL Server you are using as part of your question.

    Now, in the thread in the newbie section, I do see a link to another thread, but that was a reference link. If you took the time to read through that thread you would have seen that it explains that { fn CURDATE() } is an ODBC date function equivalent to GETDATE() or CURRENT_TIMESTAMP. If you look through your two threads you will see that some people mistook that for CURDATE() which is a MySQL date function and thought you were working with MySQL not MS SQL Server and suggested posting your question on a site dedicated to MySQL since sqlservercentral.com is a MS SQL Server centric site.

  • Lynn,

    I am sorry I posted wrongly. I have got the answer from here

    http://www.sqlservercentral.com/Forums/Topic1318719-1291-1.aspx and it has helped me to get the result what I was looking for.

    Thanks,

  • yusufm 48726 (5/7/2015)


    Lynn,

    I am sorry I posted wrongly. I have got the answer from here

    http://www.sqlservercentral.com/Forums/Topic1318719-1291-1.aspx and it has helped me to get the result what I was looking for.

    Thanks,

    Making the link easier for others:

    http://www.sqlservercentral.com/Forums/Topic1318719-1291-1.aspx

  • yusufm 48726 (5/7/2015)


    Lynn,

    I am sorry I posted wrongly. I have got the answer from here

    http://www.sqlservercentral.com/Forums/Topic1318719-1291-1.aspx and it has helped me to get the result what I was looking for.

    Thanks,

    I am glad that you were able to get the answer you needed.

    And don't worry about the double posting, people new to this site tend to do it initially. We usually just ask that you don't do it and post a link to the other thread so that others can follow the discussion. It isn't meant to be mean or anything, just trying to keep things in a single thread.

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply