?
Solved

Sqlserver 2005 query syntax help

Posted on 2008-06-25
9
Medium Priority
?
209 Views
Last Modified: 2010-04-21
I have
+ convert(varchar(10), getdate(), 112)

which is part of a concantonated query

it yields:

20080625

for its piece

I need it to show:

062508

Thanks in advance
0
Comment
Question by:MyDanes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 21867344

select replace(convert(varchar(10), getdate(),10),'-','')
0
 
LVL 8

Expert Comment

by:sbagireddi
ID: 21867364
SELECT REPLACE (CONVERT(varchar(10),getdate(),1),'/','')
0
 

Author Comment

by:MyDanes
ID: 21867399
Ok that did not work I got an error - I should have put the entire section which is:

select top 100 percent '2',right('0000000000' + cast(payment_id as varchar(10)),10) +
       right('0000000000' + replace(cast(amount as varchar(10)),'.',''),10) + '355008765102873' + convert(varchar(10), getdate(),10),'-','') as result
from CASHMGMT_PAYMENT

ONLY need to fix the getdate part so my output for the getdate portion shows:
062508

0
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 
LVL 60

Accepted Solution

by:
chapmandew earned 2000 total points
ID: 21867433
you forgot the 2nd replace:



select top 100 percent '2',right('0000000000' + cast(payment_id as varchar(10)),10) +
       right('0000000000' + replace(cast(amount as varchar(10)),'.',''),10) + '355008765102873' + replace(convert(varchar(10), getdate(),10),'-','') as result
from CASHMGMT_PAYMENT
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 21867456
huh?  why did you pick that one over mine?  your syntax was wrong in your 2nd post.
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 21867545
OK.  You just had me confused....thought I had answered something wrong.  :)
0
 

Author Closing Comment

by:MyDanes
ID: 31470646
Thanks Chapmando and sorry for the trouble
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question