Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. SELECT
  2. AutoShipItems.CustomerID,AutoShipItems.NextOrderDate,
  3. Customer.FirstName,Customer.LastName, Customer.EmailAddress
  4. FROM
  5. AutoShipItems
  6. INNER JOIN Customer ON
  7. AutoShipItems.CustomerID =Customer.CustomerID
  8. WHERE
  9. (AutoShipItems.NextOrderDate <= GETDATE())
  10. GROUP BY
  11. AutoShipItems.CustomerID, AutoShipItems.NextOrderDate,
  12. Customer.FirstName, Customer.LastName,
  13. Customer.EmailAddress
  14. ORDER BY
  15. AutoShipItems.NextOrderDate
  16.  
  17. cast(floor(cast(AutoShipItems.NextOrderDate as float)) as datetime)
  18.  
  19. create function [dbo].[xfn_TrimTimeFromDateTime]
  20. (
  21. @date as datetime
  22. )
  23. returns datetime with schemabinding as
  24. begin
  25. --- Convert to a float, and get the integer that represents it.
  26. --- And then convert back to datetime.
  27. return cast(floor(cast(@date as float)) as datetime)
  28. end
  29.  
  30. GROUP BY
  31. AutoShipItems.CustomerID,
  32. dbo.xfn_TrimTimeFromDateTime(AutoShipItems.NextOrderDate),
  33. Customer.FirstName, Customer.LastName, Customer.EmailAddress
  34.  
  35. cast (x as date)
  36.  
  37. year(x)
  38. month(x)
  39. day(x)
  40.  
  41. select convert(datetime, convert(varchar(10), getdate(), 112))
  42.  
  43. convert(date, @x)
  44.  
  45. cast(@x as date)
  46.  
  47. CREATE FUNCTION [dbo].[fn_GetDateOnly] ( @pInputDate DATETIME )
  48. RETURNS DATETIME
  49. BEGIN
  50.  
  51. RETURN CAST(CONVERT(VARCHAR(10), @pInputDate, 111) AS DATETIME)
  52.  
  53. END
  54.  
  55. SELECT AutoShipItems.CustomerID, convert(nvarchar(10), AutoShipItems.NextOrderDate, 110) as NextOrderDate ,Customer.FirstName,Customer.LastName,
  56. Customer.EmailAddress
  57. FROM AutoShipItems INNER JOIN
  58. Customer ON AutoShipItems.CustomerID =Customer.CustomerID
  59. WHERE (AutoShipItems.NextOrderDate <= GETDATE())
  60. GROUP BY AutoShipItems.CustomerID, convert(nvarchar(10), AutoShipItems.NextOrderDate, 110) , Customer.FirstName, Customer.LastName,
  61. Customer.EmailAddress
  62. ORDER BY AutoShipItems.NextOrderDate
  63.  
  64. CAST(datetime - 0.5 AS int)
  65.  
  66. CAST(CAST(datetime AS float) AS int)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement