Solved

Have time show with the date in SQL Server

Posted on 2012-04-02
2
281 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

13 Experts available now in Live!

Get 1:1 Help Now