Information générale
Forum:
Microsoft SQL Server
Versions des environnements
SQL Server:
SQL Server 2005
>>Hi
>>
>>I'm processing some csv files and I want to move the processed file to another location and rename it with a datetime string
>>
>>yyymmddhhmmss
>>
>>anyone know the easiest way to return that string from GETDATE()
>>
>>Thanks
>>
>>Nick
>
>CAST(REPLACE(REPLACE(REPLACE(convert(CHAR(19),GETDATE(),126 ),'-',''),'T',''),':','') AS CHAR(14))
T-SQL really makes you jump through hoops sometimes, doesn't it? Even getting the date portion of a datetime is verbose and ugly. It mystifies that it hasn't been simplified by now.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement