0

I want to insert UTC Date into my SQL Server table date type, my query is failing and here is my that fails

Insert into Vendor(Vendor_id,Vendor_Name,LIC_START_DATE) 
             VALUES('12345','XYZ','2020-01-01Z');

LIC_START_DATE is date type.

Could you please help on this.

Dale K
  • 25,246
  • 15
  • 42
  • 71
hh PAT
  • 1
  • 5
  • What do you mean by "it is failing" - does it give an error? Not turn up? Turn up wrong? Please clarify. – Dale K Oct 07 '20 at 19:13

1 Answers1

0

Instead of

Insert into Vendor(Vendor_id,Vendor_Name,LIC_START_DATE) 
             VALUES('12345','XYZ','2020-01-01Z');

Try

Insert into Vendor(Vendor_id,Vendor_Name,LIC_START_DATE) 
             VALUES('12345','XYZ','2020-01-01');

About UTC date/datetime in general:

To get the current UTC date:

select getutcdate();

To get the current UTC datetime2(7)

select sysutcdatetime()

To translate an existing datetime in a particular time zone to UTC datetime

declare @existing_date          datetime='2001-01-01 10:00:00';

select @existing_date at time zone 'Eastern Standard Time' at time zone 'UTC';
SteveC
  • 5,955
  • 2
  • 11
  • 24