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, 2022 in Others by polo
• 1,480 points
590 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, 2022 by nisha
• 2,210 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, 2022 in Others by anisha
• 140 points
588 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, 2022 in Others by Avinash
• 240 points
4,727 views
0 votes
1 answer

How can I use a command button in excel to set the value of multiple cells in one click?

Try this: Private Scan As Integer Private Sub CommandButton1_Click() ...READ MORE

answered Oct 24, 2022 in Others by narikkadan
• 63,600 points
782 views
0 votes
1 answer
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, 2022 in Database by Neha
• 9,020 points
1,346 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, 2022 in Database by Neha
• 9,020 points
759 views
0 votes
1 answer

Difference between datetime and timestamp in sqlserver?

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

answered Feb 16, 2022 in Database by Vaani
• 7,070 points
4,910 views
0 votes
1 answer

How to convert DateTime to VarChar

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

answered Feb 23, 2022 in Database by Neha
• 9,020 points
1,193 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, 2022 in Others by nisha
• 2,210 points
3,445 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, 2022 in Others by nisha
• 2,210 points
749 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP