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

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

stylishjm
Starting Member

17 Posts

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

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
James

karthik0805
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

bandi
Flowing Fount of Yak Knowledge

India
2223 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],
QsrUser.SpeedOfService.VirtualDisplayName,
QsrUser.SpeedOfService.LastBumpTime,
QsrUser.SpeedOfService.FirstDisplayedTime,
QsrUser.SpeedOfService.TransactionNumber 
FROM QsrUser.SpeedOfService WHERE Timestamp>= dateadd(day,-360,getdate()) 
order by [Date] desc, [Time] desc" -o "SpeedofService.csv" -h-1 -s"," -w 700


--
Chandu
Go to Top of Page

stylishjm
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  
 New 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.05 seconds. Powered By: Snitz Forums 2000