Specify date with string (OrderDate = '7/4/1996') : datetime « Data Types « SQL Server / T-SQL Tutorial

SQL Server / T-SQL Tutorial
1. Query
2. Insert Delete Update
3. Table
4. Table Join
5. Data Types
6. Set Operations
7. Constraints
8. Subquery
9. Aggregate Functions
10. Date Functions
11. Math Functions
12. String Functions
13. Data Convert Functions
14. Analytical Functions
15. Sequence Indentity
16. View
17. Index
18. Cursor
19. Database
20. Transact SQL
21. Procedure Function
22. Trigger
23. Transaction
24. XML
25. System Functions
26. System Settings
27. System Tables Views
28. User Role
29. CLR
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
SQL Server / T-SQL Tutorial » Data Types » datetime 
5. 9. 11. Specify date with string (OrderDate = '7/4/1996')
4CREATE TABLE Orders (
5>      OrderID int NOT NULL ,
6>      CustomerID nchar (5NULL ,
7>      EmployeeID int NULL ,
8>      OrderDate datetime NULL ,
9>      RequiredDate datetime NULL ,
10>     ShippedDate datetime NULL ,
11>     ShipVia int NULL ,
12>     Freight money NULL DEFAULT (0),
13>     ShipName nvarchar (40NULL ,
14>     ShipAddress nvarchar (60NULL ,
15>     ShipCity nvarchar (15NULL ,
16>     ShipRegion nvarchar (15NULL ,
17>     ShipPostalCode nvarchar (10NULL ,
18>     ShipCountry nvarchar (15NULL
19)
20> GO
1>
2>
3CREATE TABLE OrderDetails (
4>      OrderID int NOT NULL ,
5>      ProductID int NOT NULL ,
6>      UnitPrice money NOT NULL DEFAULT (0),
7>      Quantity smallint NOT NULL DEFAULT (1),
8>      Discount real NOT NULL DEFAULT (0)
9)
10> GO
1INSERT OrderDetails VALUES(10248,11,14,12,0)
2INSERT OrderDetails VALUES(10248,42,9.8,10,0)
3INSERT OrderDetails VALUES(10248,72,34.8,5,0)
4INSERT OrderDetails VALUES(10249,14,18.6,9,0)
5INSERT OrderDetails VALUES(10249,51,42.4,40,0)
6INSERT OrderDetails VALUES(10250,41,7.7,10,0)
7INSERT OrderDetails VALUES(10250,51,42.4,35,0.15)
8INSERT OrderDetails VALUES(10250,65,16.8,15,0.15)
9INSERT OrderDetails VALUES(10251,22,16.8,6,0.05)
10INSERT OrderDetails VALUES(10251,57,15.6,15,0.05)
11> go

(rows affected)

(rows affected)

(rows affected)

(rows affected)

(rows affected)

(rows affected)

(rows affected)

(rows affected)

(rows affected)

(rows affected)
1>
2>
3>    SELECT DISTINCT o.OrderDate, od.ProductID
4>    FROM Orders o
5>    JOIN OrderDetails od
6>      ON o.OrderID = od.OrderID
7>    WHERE OrderDate = '7/4/1996'
8> GO
OrderDate               ProductID
----------------------- -----------

(rows affected)
1>
2> drop table orders;
3> drop table OrderDetails;
4> GO
5. 9. datetime
5. 9. 1. datetime type
5. 9. 2. Store the date and time for a change in a datetime format.
5. 9. 3. Billings on or before a specified date
5. 9. 4. A BETWEEN phrase with literal values
5. 9. 5. Using comperison operator with Date value
5. 9. 6. Between date
5. 9. 7. SET start_Date = GETDATE()
5. 9. 8. Use 'LIKE pattern' match with a date type value
5. 9. 9. An UPDATE statement that assigns new values to datetime column with string value
5. 9. 10. CAST(OrderDate AS varchar)
5. 9. 11. Specify date with string (OrderDate = '7/4/1996')
5. 9. 12. Performing Date Conversions
5. 9. 13. SELECT CONVERT(datetime, CONVERT( varchar(11), '2005-08-13 20:37:22.570', 101))
5. 9. 14. Add integer and float number to a date value
5. 9. 15. A SELECT statement that ignores date values
5. 9. 16. A SELECT statement that uses the CONVERT function to remove time values
5. 9. 17. A SELECT statement that uses the CAST function to remove time values
5. 9. 18. A SELECT statement that searches for month, day, and year components
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.