in table having only date but after exporting in excel it is showing date with time how to remove time in excel
eg:in table date column :
date
11/12/2023
date in excel sheet:
date
11/12/2023 10:11:00 pm
excepted output in excel sheet should be like this only date :
11/12/2023

Ali BenchaabanRank #925 · 2.2K reputationPosted Mar 29, 2023, 9:48 AM EDT
Hello Meghana,
Try to use select convert(nvarchar, "your date column name ", 103)
BENCHAABAN Ali
Rajkiran SwainRank #165 · 14.4K reputationPosted Mar 29, 2023, 4:20 PM EDT
SELECT CONVERT(date, MyDate) AS MyDateOnly FROM MyTableMeghana MRank #8,429 · 222 reputationPosted Mar 29, 2023, 10:33 PM EDT
date format is correctly displaying in excel but date is not proper
Raj BhattRank #513 · 4.8K reputationPosted Mar 30, 2023, 2:16 AM EDT
Hello ,
Please Try This
SELECT CONVERT(nvarchar, convert(date, '11/12/2023 10:11:00 pm', 101), 101) As DateFormatPratik Patel19 reputationPosted Mar 30, 2023, 5:08 AM EDT
In the SQL Server, Here is multiple options for removing time from datetime column. We can use CONVERT or CAST function by converting the datetime to date type only.
For Example
DECLARE @CurrentDate DateTime = GetDate()
SELECT @CurrentDate As CurrentDateTime
--OptionNo.1
SELECT CONVERT(DATE,@CurrentDate) AS OptionNo.1
--OptionNo.2
SELECT CAST(@CurrentDate AS DATE) AS OptionNo.2
--OptionNo.3
SELECT CONVERT(char(10), @CurrentDate,126) AS OptionNo.3