How to convert DateTime to VarChar

0 votes
I'm trying to convert a value from a DateTime variable to a varchar variable using the yyyy-mm-dd format (without time part).

How can I go about doing that?
Feb 22, 2022 in Database by Vaani
• 7,060 points
952 views

1 answer to this question.

0 votes

With Microsoft Sql Server:

--
-- Create test case
--
DECLARE @myDateTime DATETIME
SET @myDateTime = '2020-06-02'

--
-- Convert string
--
SELECT LEFT(CONVERT(VARCHAR, @myDateTime, 100), 20)
answered Feb 23, 2022 by Neha
• 9,060 points

Related Questions In Database

0 votes
0 answers

How to convert SQL Server's timestamp column to datetime format

Is there a simple way to convert ...READ MORE

Aug 21, 2022 in Database by Kithuzzz
• 38,010 points
1,407 views
0 votes
1 answer

SQL Server Convert Varchar to Datetime

Try this: SELECT CONVERT(Datetime, '2011-09-28 18:01:00', 120) -- ...READ MORE

answered Sep 13, 2022 in Database by narikkadan
• 63,720 points
5,777 views
0 votes
1 answer

how to Convert EST time to IST time in excel?

Use the following calculation since Indian Standard ...READ MORE

answered Mar 25, 2022 in Database by gaurav
• 23,260 points
1,593 views
0 votes
1 answer

How to convert a column number (e.g. 127) into an Excel column (e.g. AA)

If anyone needs to do this in ...READ MORE

answered Mar 30, 2022 in Database by gaurav
• 23,260 points
793 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,060 points
4,532 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, 2022 in Database by Neha
• 9,060 points
1,154 views
0 votes
1 answer

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

Your dates are interpreted as MM-DD-YYYY. This ...READ MORE

answered Jun 21, 2022 in Others by nisha
• 2,210 points
424 views
0 votes
0 answers

How to convert java.util.Date to java.sql.Date?

I need a java.sql since I'm trying ...READ MORE

Aug 11, 2022 in Database by Kithuzzz
• 38,010 points
571 views
0 votes
1 answer

How to drop all tables from a database with one SQL query?

Use the INFORMATION_SCHEMA.TABLES view to get the ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,060 points
8,643 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,060 points
605 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