Solved

sql server, sql command to convert date to yyyymmdd format

Posted on 2011-03-10
8
952 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

863 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

19 Experts available now in Live!

Get 1:1 Help Now