Sql-docs: correct comma position

Created on 24 Dec 2019  Â·  2Comments  Â·  Source: MicrosoftDocs/sql-docs

Is this the correct syntax?
FORMAT ( value, format [, culture ] )
Isn't it like that?
FORMAT ( value, format, [ culture ] )
I'm not sure that's why I'm asking.
Best regards!


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

cba product-question sqprod

All 2 comments

FORMAT ( value, format [, culture ] ) is correct. Parts inside the brackets ([]) are optional. If FORMAT ( value, format, [ culture ] ) were the correct syntax, then when you omit a value for culture you would have to have a trailing comma (,):

SELECT FORMAT(GETDATE(),'dd/MM/yyyy',);

If you try that, you'll get an error.

@trynio -- thank you for your question.

@LarnuUK -- thank you for your answer :^)

I am closing this issue now. You are welcome to @ mention me for any followup.
We hope to hear from you again.

Was this page helpful?
0 / 5 - 0 ratings