Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

GetDateTimeString Function

By Luis Atondo,

To use this function:

 

DECLARE @DTest NVARCHAR(12)

SET @DTest=dbo.GetDateTimeString(getdate())

SELECT @DTest as Test,getdate()

 

Result : '200907111405'


DECLARE @DTest NVARCHAR(12)

SET @DTest=dbo.GetDateTimeString('01/05/2009 2:00 PM')

SELECT @DTest as Test

 

Result : '200901051400'

 

 

 

Total article views: 921 | Views in the last 30 days: 1
 
Related Articles
SCRIPT

GetDateTime Function

This function gets a variable string and converts to DateTime format 'YYYY-MM-DD HH:MM' Ex. '200...

FORUM

stored procedures / batch file

Hi, I have a single test.sql file with about 7 stored procedures in it. create proc xxx1 as .......

FORUM

Truncating Transaction Logs

We are writing queries to determine if a transaction log was truncated since the last backup.  We ha...

FORUM

Need help for SQLCMD

Post by Dhananjay

FORUM

Migrating isql command to sqlcmd in SQL 2005 Issue

Format of the field returned in the output of isql & SQLCMD is different

Tags
cast    
convert    
datepart    
datetime    
function    
len()    
 
Contribute