Hi,

I've run into a problem with SQL syntax that drives me *&&*%!!*:

I need to retrieve a large data set from a SQL Server database. The data set
includes DATETIME fields, and my problem is that I need to FORCE the date
format to be
yyyy/MM/dd - WITH MM AND DD ALWAYS BEING TWO CHARACTERS. In other words, 8
April 2004 should be returned as 2004/04/08 and not 2004/4/8 (which happens
now).

This format is necessary to ensure correct sorting during subsequent
processing in our Web Pivot Reporter utility, where these dates are sorted
as if they were text.

I have tried varieties of the following, but cannot make it return what I
need:

(cast(DATEPART(yyyy, ValidTo) as nvarchar(4)) + '/' + cast(DATEPART(MM,
ValidTo) as nvarchar(2)) + '/' + cast(DATEPART(dd, ValidTo) as nvarchar(2)))
as PeriodEnd

Any good ideas?

regards
calle

*********************************************
Calle Hedberg
46D Alma Road,
7700 Rosebank, SOUTH AFRICA
Tel/fax (home): +27-21-685-6472;  Cell: +27-82-853-5352
*********************************************

Reply via email to