In Feburary 2016 23,
Create a new query statement in SQL to extract a date from the database. However, instead of extracting the raw data value stored in the database, use the 'Date_Format' command in conjunction with the query to ensure the extracted date is in your desired format.
Enter the name of the database variable that represents the raw date value as the first parameter in the 'Date_Format' command. This command uses two parameters separated by a comma inside the command's parenthesis. The format is 'Date_Format(date, format)'.
Identify the SQL date format codes that represent the many date formats that SQL may output. These codes cover all conceivable date formats and may be arranged in any order. Each code begins with a percent sign and is followed by a letter which represents a portion of a date displayed in a particular fashion. For example, '%Y' is the four-digit year, while '%y' is the two-digit year.
Format the second parameter of the 'Date_Format' command using SQL date codes to match the desired output format of the date that is extracted from the database. For example, to create a verbose text output of the date, use '%W, %M %e, %Y'. This date format will appear as 'Sunday, April 18, 2010'. Commas are entered in the format where they should appear in the final output.
Format the date as a numerical string by typing 'Date_Format([date],'%e-%c-%Y')'. Note that the single quotes are not included in the actual typed SQL query. Use the actual name of the database variable for '[date]' in this example. The output will resemble '18-4-2010'.
In Feburary 2016 23,