How Can I use Date Datatype in sql server

0 votes

 To create column in table with data type "Date" it gives me error and I can't add it here is my code

Create table Orders (
Order_ID INT Primary Key,
Book_name varchar(100) ,
isbn varchar(100) ,
Customer_ID INT Foreign key references Customer,
Order_date date,
);

another thing it requires from me to get date of something which is before created one

to be more clear: the query asked indicates to find date before 2 of August How can I do that

Jun 20 in Others by polo
• 1,500 points
13 views

1 answer to this question.

0 votes

Your dates are interpreted as MM-DD-YYYY. This intrepretation is depenent on your system's culture. The first three are turning into wrong dates but work. The 4th breaks and the fifth is never executed (due to the error before).

So the actual error lies on line 4.

Whenever you deal with dates, use culture independent formats. It is better to use either of the following-

universal format

20150730 (=> the 30th of July in 2015)

ODBC-format

{d'2015-07-30'} or {t'23:30:59'} or {ts'2015-07-30 23:30:59'}
answered Jun 21 by nisha
• 2,160 points

Related Questions In Others

0 votes
1 answer

How do I UPDATE from a SELECT in SQL server?

In SQL Server, it is possible to insert ...READ MORE

answered May 30 in Others by anisha
• 140 points
17 views
0 votes
1 answer

How can we UPDATE from a SELECT in an SQL Server

We can firstly use SELECT statement to fetch ...READ MORE

answered May 27 in Others by Avinash
• 240 points
32 views
0 votes
0 answers

how can I deploy a test in pytest framework to airflow using DAG?

I have established an automative testing framework ...READ MORE

Oct 4, 2021 in Others by Yuan
• 120 points
35 views
0 votes
1 answer

How Can I use "Date" Datatype in sql server?

There's problem in all of them and ...READ MORE

answered Feb 9 in Database by Neha
• 8,560 points
68 views
0 votes
1 answer

How to rename a column in a database table using SQL?

For SQL Server, use sp_rename USE AdventureWorks; GO EXEC sp_rename 'Customers.CustomerTerritory.TerritoryID', ...READ MORE

answered Feb 9 in Database by Neha
• 8,560 points
67 views
0 votes
1 answer

Difference between datetime and timestamp in sqlserver?

Timestamp is a synonym for rowversion, according ...READ MORE

answered Feb 16 in Database by Vaani
• 7,020 points
392 views
0 votes
1 answer

How to convert DateTime to VarChar

With Microsoft Sql Server: -- -- Create test case -- DECLARE ...READ MORE

answered Feb 23 in Database by Neha
• 8,560 points
28 views
0 votes
1 answer

How can i create file at external storage in Android?

We have not had read/write filesystem access ...READ MORE

answered Jun 6 in Others by nisha
• 2,160 points
25 views
0 votes
1 answer

How to delete duplicate rows in SQL Server?

WITH CTE AS ( SELECT *,ROW_NUMBER() OVER (PARTITION BY ...READ MORE

answered Jun 21 in Others by nisha
• 2,160 points
15 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP