Method 1: Select convert (varchar, getdate (), 120) 11:06:08 Select Replace (replace (convert (varchar, getdate (), 120 ),/'-/',/'/'),/'/', /'/'),/':/',/'/') 20040912110608 H Select convert (varchar (12), getdate (), 111) 2004/09/12 Select convert (varchar (12), getdate (), 112) 20040912 Select convert (varchar (12), getdate (), 102) 2004.09.12 Select convert (varchar (12), getdate (), 101) 09/12/2004 Select convert (varchar (12), getdate (), 103) 12/09/2004 Select convert (varchar (12), getdate (), 104) 12.09.2004 Select convert (varchar (12), getdate (), 105) 12-09- Select convert (varchar (12), getdate (), 106) 12 09 2004 Select convert (varchar (12), getdate (), 107) 09 12,200 4 Select convert (varchar (12), getdate (), 108) 11:06:08 Select convert (varchar (12), getdate (), 109) 09 12, 2004 1 Select convert (varchar (12), getdate (), 110) 09-12-2004 Select convert (varchar (12), getdate (), 113) 12 09 2004 1 Select convert (varchar (12), getdate (), 114) 11:06:08. 177 Method 2: Declare @ TT varchar (4), @ pp varchar (8), @ SS varchar (4), @ AA varchar (16) Set @ TT = rtrim (cast (month (getdate () as varchar (10 ))) Set @ Ss = rtrim (cast (Day (getdate () as varchar (10 ))) Select @ pp = rtrim (cast (Year (getdate () as varchar (10 ))) Select @ AA = @ pp + @ tt + @ SS Select @ AA Show only the year and month, not the day: Select datepart (year, getdate () * 100 + datepart (month, getdate ()) 200811 Select Year (orderdate) as YY, sum (freighttotmon) as price from [order] group by year (orderdate) Select Year (orderdate) as YY, month (orderdate) as Mon, sum (freighttotmon) as price from [order] group by month (orderdate), Year (orderdate) Select orderdate as date, sum (freighttotmon) as price from [order] group by orderdate -- Select orderdate as date, freighttotmon as price from [order] -- Select convert (varchar (12), orderdate, 111) as date, sum (freighttotmon) as price from [order] group by orderdate -- Select datepart (year, orderdate) * 100 + datepart (month, orderdate) as date, sum (freighttotmon) as price from [order] group by datepart (year, orderdate) * 100 + datepart (month, orderdate) |