Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need to pad string values
Message
De
07/12/2001 09:56:05
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Need to pad string values
Divers
Thread ID:
00591126
Message ID:
00591126
Vues:
56
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)
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform