April 16, 2019 at 5:59 pm
Afternoon,
I'm working on encoding a json token and I'm getting this - "Conversion failed when converting date and/or time from character string"
Ex:
--2016 compatibility
declare @data varbinary(max)
declare @base64string varchar(max)
select @data = convert(varbinary(max), '{"note":"ALL THESE WORLDS ARE YOURS...","iat":' + getdate() + ', "valid":"true"}');
select @base64string = cast('' as xml).value('xs:base64Binary(sql:variable(''@data''))', 'varchar(max)')
Any help,
Thanks!
Code-Blooded
April 16, 2019 at 8:21 pm
You need to explicitly convert getdate(), for example:
CONVERT(CHAR(8), GETDATE(), 112)
--Vadim R.
April 16, 2019 at 8:59 pm
That worked perfect. Thanks for the reply!
Code-Blooded
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply