Solved

Have time show with the date in SQL Server

Posted on 2012-04-02
2
285 Views
Last Modified: 2012-06-27
I have the following code which shows date... Ex:(02/06/2012)
convert(varchar, CAST(TS_Day2 as datetime),101) as Expected,

I also have code that shows the date and time... Ex:(Feb 6 2012 7:15AM)
CONVERT(varchar(20), CAST(a.Expected AS datetime), 100) as Expected,

What code do I use if I want... 01/06/2012 7:15AM?
I don't want Jan, Feb, I want 01 and 02.
0
Comment
Question by:BobRosas
2 Comments
 
LVL 21

Accepted Solution

by:
JestersGrind earned 150 total points
ID: 37797476
You could do something like this.

SELECT CONVERT(VARCHAR, CAST(TS_Day2 AS DATETIME),101) + SUBSTRING(CONVERT(VARCHAR, CAST(TS_Day2 AS DATETIME),100), 12, 10) AS Expected

Open in new window


Greg
0
 

Author Closing Comment

by:BobRosas
ID: 37797523
Worked great!  Thank you so much!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error Creating Foreign Keys in SQL Database 7 32
tempdb log contention 16 38
Help Required 2 29
MS SQL + Insert Into Table - If Doesnt Exist 9 32
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

815 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

8 Experts available now in Live!

Get 1:1 Help Now