Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sql server, sql command to convert date to yyyymmdd format

Posted on 2011-03-10
8
Medium Priority
?
990 Views
Last Modified: 2012-05-11
I had this command;
"CONVERT(VARCHAR,issdate,112) issdate, "
I thought this was converting the date (in date format) to character type yyyymmdd, but I just noticed the date format is back again.

Is the above right command to convert date to yyyymmdd?  I am using vb.net with sql server 2003
Thanks
0
Comment
Question by:CPOINT2000
[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
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 5

Expert Comment

by:mayankagarwal
ID: 35097600
0
 
LVL 5

Assisted Solution

by:mayankagarwal
mayankagarwal earned 100 total points
ID: 35097609
check this link to create a function to accomplish the same task
http://sqlserver2000.databases.aspfaq.com/can-i-make-sql-server-format-dates-and-times-for-me.html
0
 
LVL 8

Accepted Solution

by:
pdd1lan earned 400 total points
ID: 35097630
try it:
CONVERT(CHAR(8), issdate, 112)
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 71

Expert Comment

by:Qlemo
ID: 35097693
Since your original convert function was almost correct (varchar versus char - doesn't make a big difference), I assume your application is still reading that as a date, and hence doing conversion again, and all the convert does for you then is to cut off the time portion.

BTW, you won't use MSSQL 2003 ;-).
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 35097723
In which way did those comments help?
0
 

Author Comment

by:CPOINT2000
ID: 35097916
Sorry, I am fairly new to EE, and just trying to figure out EE as well.  In case of my question, it was silly really.  I was in mid's of about dozen deadlines (who isn't), and somehow I had inadvertently changed my code, which was cutting off the 112 from the command.  Although I had displayed 112 in the original question, it was not in my functional program (at run time).   I accepted the solution from pdd1lan because that kind a woke me up.

0
 

Author Comment

by:CPOINT2000
ID: 35098150
Thanks for clarification, understood.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

609 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