Solved

datetime format

Posted on 2011-09-20
11
273 Views
Last Modified: 2012-05-12
convert(varchar, dateSubmitted, 110) as dateSubmitted just gives me date a 08/15/2011 format and I want to also see time beside the date how to do that.. tsql
0
Comment
Question by:1jaws
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36569902
If you want to see the date and time, then why use the CONVERT function at all?
0
 
LVL 18

Expert Comment

by:lludden
ID: 36569957
You can use CONVERT(varchar(20),DateSubmitted,0).  Look at the table in BOL to see what all the convert options do.
0
 

Author Comment

by:1jaws
ID: 36570337
I need to use such as 08/15/2011 on the date part.. shows me Aug 15 2011
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 18

Expert Comment

by:lludden
ID: 36570458
Then you need to combine two:

SELECT convert(varchar(8),DateSubmitted,101) + ' ' + convert(varchar(5),DateSubmitted,108)
0
 

Author Comment

by:1jaws
ID: 36570483
still not right... it shows me as 08/15/20
0
 
LVL 18

Assisted Solution

by:lludden
lludden earned 250 total points
ID: 36570514
Because I can't count.

SELECT convert(varchar(10),DateSubmitted,101) + ' ' + convert(varchar(5),DateSubmitted,108)
0
 

Author Comment

by:1jaws
ID: 36570529
still need a see AM, PM also :)
0
 
LVL 32

Accepted Solution

by:
ewangoya earned 250 total points
ID: 36570728

select CONVERT(varchar(10), dateSubmitted, 101) + ' ' +
       RIGHT(CONVERT(varchar, dateSubmitted, 100), 8)
0
 

Author Comment

by:1jaws
ID: 36570741
thank you ewangoya! it works.. Ok, how should I give points now? :)
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 36570748

At your discretion, you can split or award all points according to the relevance and correctness of the solution
0
 

Author Closing Comment

by:1jaws
ID: 36570750
Thanks Guys!
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Connection to multiple databases 13 26
Sum particular field in database 2 16
SQL group by query to return records with highest value 6 25
Stored Proc - Rewrite 42 61
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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