Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
tranquilraven
Starting Member
19 Posts |
Posted - 2012-06-07 : 17:20:40
|
Is it possible to pull only items with todays date? The date column is formatted as Date, so it pulls date and time. I want to just pull the data for each day, so like todays reports are today's date, tomorrow it will pull tomorrows data, etc.SELECT OrderDate AS 'Order Date', PaymentAmount AS 'Total Payments', TotalShippingCost AS 'Shipping Received', SalesTax1 AS 'Sales Tax Received', PaymentDeclined AS ' Payment Declined'FROM OrdersWHERE PaymentDeclined IS NULLORDER BY OrderDate DESC |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-06-07 : 17:31:17
|
| [code]SELECT OrderDate AS 'Order Date', PaymentAmount AS 'Total Payments', TotalShippingCost AS 'Shipping Received', SalesTax1 AS 'Sales Tax Received', PaymentDeclined AS ' Payment Declined'FROM OrdersWHERE PaymentDeclined IS NULL AND OrderDate >= CAST(SYSDATETIME() AS DATE) AND OrderDate < DATEADD(DAY, 1, CAST(SYSDATETIME() AS DATE))ORDER BY OrderDate DESC[/code] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-07 : 22:28:36
|
quote: Originally posted by Lamprey
SELECT OrderDate AS 'Order Date', PaymentAmount AS 'Total Payments', TotalShippingCost AS 'Shipping Received', SalesTax1 AS 'Sales Tax Received', PaymentDeclined AS ' Payment Declined'FROM OrdersWHERE PaymentDeclined IS NULL AND OrderDate >= CAST(SYSDATETIME() AS DATE) AND OrderDate < DATEADD(DAY, 1, CAST(SYSDATETIME() AS DATE))ORDER BY OrderDate DESC
is there any advantage of using SYSDATETIME over GETDATE in above scenario as anyways we're comparing against a open close interval.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|