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 in Database by Vaani
• 5,040 points
17 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 by Neha
• 6,260 points

Related Questions In Database

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 in Database by Edureka
• 8,820 points
38 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 in Database by Edureka
• 8,820 points
21 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 30 in Database by Edureka
• 8,820 points
39 views
0 votes
1 answer

How to Convert Excel Numeric Cell Value into Words

To translate numbers to words, create the ...READ MORE

answered Mar 31 in Database by Edureka
• 8,820 points
24 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
• 5,040 points
123 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
• 6,260 points
44 views
0 votes
1 answer

Calculate Time Intersection to Correlate Sequences of Independent Events

I think this solution requires a CROSS JOIN implementation. ...READ MORE

answered Oct 26, 2018 in Power BI by Upasana
• 8,620 points
280 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3 in Database by Vaani
• 5,040 points
34 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 in Database by Neha
• 6,260 points
87 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
• 6,260 points
52 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