Solved

sql server, sql command to convert date to yyyymmdd format

Posted on 2011-03-10
8
948 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
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 5

Expert Comment

by:mayankagarwal
ID: 35097600
0
 
LVL 5

Assisted Solution

by:mayankagarwal
mayankagarwal earned 25 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 100 total points
ID: 35097630
try it:
CONVERT(CHAR(8), issdate, 112)
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 68

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 68

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now