• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 994
  • Last Modified:

sql server, sql command to convert date to yyyymmdd format

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
CPOINT2000
Asked:
CPOINT2000
  • 2
  • 2
  • 2
  • +1
2 Solutions
 
mayankagarwalCommented:
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
 
pdd1lanCommented:
try it:
CONVERT(CHAR(8), issdate, 112)
0
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.

 
QlemoC++ DeveloperCommented:
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
 
QlemoC++ DeveloperCommented:
In which way did those comments help?
0
 
CPOINT2000Author Commented:
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
 
CPOINT2000Author Commented:
Thanks for clarification, understood.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now