[AccessD] OT: SQL SERVER Format Date

Stuart McLachlan stuart at lexacorp.com.pg
Thu Apr 15 17:58:07 CDT 2004


On 15 Apr 2004 at 15:30, Millard,	Paul --- Sr. Develop wrote:

> Hi,
> 
> I know this isn't the right forum to ask but I need help formatting date from the SQL Server default output into "mm/dd".  The query results are reported in an asp page.
> 
> Thanks in advance,
> Paul Millard
> 
> 
> Here is my query and results....
> 
> ----query----
> set 
> datefirst 1 
> select top 13 
> Week = (DateAdd(day, (-1 * datepart(dw, t1.ReqEntryDate)) + 1, t1.ReqEntryDate))
> from tblPrFieldSales t1 where t1.ReqEntryDate >= '3/1/2004' 
> order by Week DESC   
> 
> ----results----
> 2004-04-12 00:00:00.000
> 2004-04-12 00:00:00.000
> 2004-04-12 00:00:00.000
> 2004-04-12 00:00:00.000
> 
> ----ideal results----
> 04/12
> 04/12...
>  

Try

Week = Convert(char(5), (DateAdd(day, (-1 * 
datepart(dw,t1.ReqEntryDate)) + 1, t1.ReqEntryDate)),1)




 
-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System Support.






More information about the AccessD mailing list