Solved

.NET: How to check whether a time is AM or PM

Posted on 2008-10-14
2
200 Views
Last Modified: 2013-12-17
Hi, I there any way I can check whether a time is AM or PM in C#? Or I have to do all the logic myself?
0
Comment
Question by:karakav
2 Comments
 
LVL 1

Accepted Solution

by:
MarkMyburgh earned 500 total points
ID: 22709856
not sure, but i suppose a simple hack would be

DateTime x = new DateTime(2008, 1, 1, 14, 0, 0);
bool am = x.TimeOfDay.Hours >= 13 ? false : true;
 
0
 
LVL 4

Author Closing Comment

by:karakav
ID: 31505818
Thanks. That's exactly what I needed. But Correct it this way: bool = x.Value.TimeOfDay.Hours >13?false:true;
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
.NET Error 7 42
ASP.NET reading ATOM 2 26
Get Reply from SSIS to intranet site when finished 3 13
Adjust the position 3 13
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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.

760 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

16 Experts available now in Live!

Get 1:1 Help Now