Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need to pad string values
Message
From
07/12/2001 09:56:05
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Need to pad string values
Miscellaneous
Thread ID:
00591126
Message ID:
00591126
Views:
55
In the table there's a datetime column.

The following syntax converts this to two char columns, and it works fine, and it's fast.
SELECT DISTINCT TOP 100 PERCENT Member_Id,
   RTRIM(CAST(DATEPART(yyyy, [Interval]) AS char))
   + '.' + RTRIM(CAST(DATEPART(mm, [Interval]) AS char))
   + '.' + RTRIM(CAST(DATEPART(dd, [Interval]) AS char)) AS Dates,
   RTRIM(CAST(DATEPART(hh, [Interval]) AS char))
   + '.' + RTRIM(CAST(DATEPART(mi,[Interval]) AS char))
   + '.' + RTRIM(CAST(DATEPART(ss, [Interval]) AS char)) AS Times
FROM dbo.Detail
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Next
Reply
Map
View

Click here to load this message in the networking platform