Forum Discussion
ajupulickal
May 10, 2022Copper Contributor
SQL Date Formatting
Hi all, I have a requirement to do an OpenQuery to an Oracle database and the accepted time format in Oracle is "2022-05-01T06:00:00Z". I am wondering how do we convert a normal datetime in SQL s...
LainRobertson
May 10, 2022Silver Contributor
Hey, Aju.
As you've already noted, there's no pre-canned identifier that will produce that exact format. Rather, you have to do it yourself using FORMAT.
Here's an example - noting that you should probably also give preference to using GETUTCDATE() over GETDATE():
SELECT FORMAT(GETUTCDATE(), 'yyyy-MM-ddTHH:mm:ssZ')
Cheers,
Lain