Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with splitting date & time
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

17 Posts

Posted - 09/28/2012 :  07:24:10  Show Profile  Reply with Quote

I have the following code in a batch file that runs every night. It exports restaurant speed of service times.

sqlcmd -S SERVER\01 -d Office -E -Q "SELECT DISTINCT QsrUser.SpeedOfService.Timestamp,QsrUser.SpeedOfService.VirtualDisplayName,QsrUser.SpeedOfService.LastBumpTime,QsrUser.SpeedOfService.FirstDisplayedTime,QsrUser.SpeedOfService.TransactionNumber FROM QsrUser.SpeedOfService WHERE Timestamp>= dateadd(day,-360,getdate()) order by Timestamp desc" -o "SpeedofService.csv" -h-1 -s"," -w 700

However, I require the date and time to be divided, rather than showing within one "column" as yymmdd hhmmss so that the CSV will display as yymmdd, hhmmss,

Is this possible?

Thank you

Starting Member

14 Posts

Posted - 09/28/2012 :  07:31:40  Show Profile  Reply with Quote
SELECT CONVERT(VARCHAR(50),'datetimecolumn',105),CONVERT(VARCHAR(50),'datetimecolumn',108)
Go to Top of Page

Flowing Fount of Yak Knowledge

2242 Posts

Posted - 09/28/2012 :  07:47:18  Show Profile  Reply with Quote

sqlcmd -S SERVER\01 -d Office -E -Q 
"SELECT DISTINCT CONVERT(VARCHAR(50),QsrUser.SpeedOfService.Timestamp,105) AS [Date],
CONVERT(VARCHAR(50),QsrUser.SpeedOfService.Timestamp,108) AS [Time],
FROM QsrUser.SpeedOfService WHERE Timestamp>= dateadd(day,-360,getdate()) 
order by [Date] desc, [Time] desc" -o "SpeedofService.csv" -h-1 -s"," -w 700

Go to Top of Page

Starting Member

17 Posts

Posted - 09/28/2012 :  08:01:28  Show Profile  Reply with Quote
Perfect that worked as wanted. Thanks Guys!
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000