We help IT Professionals succeed at work.
Get Started

Varchar Datetime to Varchar Date in SQL

876 Views
Last Modified: 2012-05-10
Team,

I have a field (Varchar(255)) in a table which always have inputs like

12/29/2010 7:31:37 AM
12/30/2010 7:27:05 AM
1/3/2011 7:29:04 AM


Till Date, i was using the below formula to do a look up

select Convert(varchar, getdate(),101) as 'BacklogDate', Convert(varchar, getdate(),7) as 'Today'

however since the date i have in the table has 1/3/2011 7:29:04 AM, and the query i wrote populates, 01/03/2011, its not matching due to preceding zeros.

I need to have a query which does both with / without preceding zeros.

Help me.

Thanks,
David
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2012
Commented:
This problem has been solved!
Unlock 2 Answers and 11 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE