

You can also combine these format strings to provide your own customized date format. You can also add tt to include the AM/PM designator: SELECT FORMAT( GETDATE(), 'hh.mm tt') Here’s an example: SELECT FORMAT( GETDATE(), 'hh.mm') You can also use the FORMAT() function to return the time in a specified format.
#Neooffice date format code#
MonthĮxample code for returning the month part: SELECT FORMAT( GETDATE(), 'MMM') Įxample code for returning the year part: SELECT FORMAT( GETDATE(), 'yyyy') Įxample code for returning the day part: SELECT FORMAT( GETDATE(), 'dddd') For example, MMM formats the month differently to mmm. You can use the FORMAT() function to return only the month part of the date, or the week, or year as required. See How Language Settings can Affect your FORMAT() Results for more examples. In any case, you can also find out what the default language is.Īs you might imagine, you could get quite different results depending on your current language or the value of any “culture” argument. Note that the current language will usually be the same as the user’s default language, but this might not be the case if the user has changed the current language using SET LANGUAGE.
#Neooffice date format how to#
Here’s how to find the language of the current session, and here’s how to set it. If the culture argument is not provided, the language of the current session is used. Here’s another example: SELECT FORMAT( GETDATE(), 'd', 'zh-cn') So we could do this for example: SELECT FORMAT( GETDATE(), 'd', 'en-gb') We could add a third (“culture”) argument to the above code to determine the locale to use for the date’s format. By default, the language of the current session is used, but you can also override this with a third (“culture”) argument. The actual results will vary depending depending on the culture being used. Here’s another: SELECT FORMAT( GETDATE(), 'd') This is just one of many formats that we could choose. Which results in this: Thursday, May 3, 2018 For example, we could do this: SELECT FORMAT( GETDATE(), 'D') Now, we can use the FORMAT() function to format that date and time into our preferred format. We get a result that looks something like this: 02:36:54.480 If we run the following statement: SELECT GETDATE() Raw Dateįirst, here’s what the raw date looks like. Here’s a basic example of using the FORMAT() function to format a date. The FORMAT() function also accepts an optional “culture” argument, which allows you to specify a language/locale that the results should adhere to. A format string defines how the output should be formatted. The format is supplied as a format string. Simply provide two arguments the date/time and the format to use. In SQL Server, you can use the T-SQL FORMAT() function to format the date and/or time.
