Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I work on sql server 2017 i have date field name datelogged with datatype

datetime2(7)
my table structure as below

SQL
CREATE TABLE [dbo].[print_report](
    [ID] [int] NOT NULL,
    [datelogged] [datetime2](7) NULL,
 CONSTRAINT [PK_print_report] PRIMARY KEY CLUSTERED 
(
    [ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

when copy date time value from excel to sql server 2017 time value changed .

why and how to prevent time value from changed from 12 hours to 24 hours.

What I have tried:

SELECT CONVERT(CHAR(11), DATEADD(DAY, 10, GETDATE()), 13);
Posted
Updated 28-Jan-23 22:19pm
v2

1 solution

Sounds like the formatting is off at Excel side.
Have a look at Format a date the way you want - Microsoft Support[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900