Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6597449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:12:38+00:00 2026-05-25T18:12:38+00:00

Consider an Excel sheet with one column of bad data. We have a table

  • 0

Consider an Excel sheet with one column of bad data. We have a table that can be used to correct the data. My code runs it by writing a new sheet containing the old sheet plus adding new columns of correct data for them to compare.

This date is fine and works but it makes the date/time into a format with 24-h time.

How can this be changed to use the preferred format?

newSheet.Cells[i + 2, 3] = drugorder.DATE;
newSheet.Cells[i + 2, 3].NumberFormat = "m/d/yyyy h:mm"; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:12:40+00:00Added an answer on May 25, 2026 at 6:12 pm

    Apparently, the h specifier in an Excel date format will only use 12-hour time if you include an AM/PM specifier in the number format as well.

    The seemingly logical .NumberFormat = "m/d/yyyy h:mm" produces:

    2/13/1922 5:19
    5/17/1927 21:13
    

    While .NumberFormat = "m/d/yyyy h:mm AM/PM" produces the intended:

    2/13/1922 5:19 AM
    5/17/1927 9:13 PM
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OLEDB can be used to read and write Excel sheets. Consider the following code
Consider that I've a excel sheet in below format: person age Foo 29 Bar
I have one Excel document with two sheets Sheet1 and Sheet2. Sheet1 data is
I have a "duration" column in an Excel sheet. Its cell format always changes
Consider i have an excel file >200000 rows in it. What is the fastest
i am using vsto, to work with excel-2007... let's consider i have a matrix
Consider the following data source: declare @Test table (EmpId int, ProdId int, Sold int)
Consider this query that uses SELECT * and 'appends' a calculated column: SELECT *,
I have written an ASP.NET web page with C# behind that runs an existing
Consider the following case: I have a single Excel workbook with 4 sheets in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.