Dates are not stored in any format in SQL Server. A client application formats dates.
You can modify your query as follows to get date as varchar
value in needed format.
SELECT
RIGHT(CONVERT(varchar(12),ExpDate,103),7) ExpDate
FROM
myTable
Question
Say I have the following date format in my SQL Server database: 3/2007
but when I try to get the data via CFML script I get it this altered format 2007-03-31 00:00:00.0
, my script looks like this:
<cfquery name="header" datasource="mydb">
SELECT
ExpDate
FROM
myTable
</cfquery>
<CFOUTPUT>ExpDate</CFOUTPUT>
<cfloop query="header">
<CFOUTPUT>#ExpDate#</cfoutput>
</cfloop>
Any idea why my date format is altered? Thanks!
Solution
Dates are not stored in any format in SQL Server. A client application formats dates.
You can modify your query as follows to get date as varchar
value in needed format.
SELECT
RIGHT(CONVERT(varchar(12),ExpDate,103),7) ExpDate
FROM
myTable