Posted on 2009-07-11
Last Modified: 2012-05-07
I'm new to SQL.
Here's my question,
I need to get the hour and minutes to show like hm, example (832 or 1125 or ...),
I used this :

SELECT DATEPART(minute,My Field)  

it gives me the info, but I can't seem able to combine both.

Thanks for any help.
Question by:wassimqa
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 75

Accepted Solution

Aneesh Retnakaran earned 500 total points
ID: 24830849
SELECT cast(REPLACE(CONVERT(varchar(5),getdate(), 108),':','') AS INT)
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 500 total points
ID: 24830871
SELECT  CAST( DATEPART(hour,My Field) as varchar ) +
               CAST( DATEPART(minute,My Field)  as varchar )

Author Comment

ID: 24830880
I get a syntax error when using
SELECT cast(REPLACE(CONVERT(varchar(5),MY Field 108),':','') AS INT)

My field looks like: May 29 2008  8:22AM
Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 500 total points
ID: 24830915
did you miss the comma

SELECT cast(REPLACE(CONVERT(varchar(5),[MY Field] ,108),':','') AS INT)

Author Comment

ID: 24831003
yes, I missed the comma,
Beginners mistake,
Thanks again.

Author Closing Comment

ID: 31602434
excellent work

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

724 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