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 8186441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:11:58+00:00 2026-06-07T02:11:58+00:00

I have results from a database search where some columns have dates, but not

  • 0

I have results from a database search where some columns have dates, but not others. I need help to write

data = [['556644', 'Mr', 'So', 'And', 'So', Decimal('0.0000'), datetime.datetime(2012, 2, 25, 0, 0), '', False, datetime.datetime(2013, 6, 30, 0, 0)],...]

into an Excel spreadsheet so that

easyxf(num_format_str='DD/MM/YYYY')

is only applied to the datetime columns. I’m quite new to Python and I’ve been banging my head on this for quite a few days now. Thanks!

  • 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-06-07T02:12:00+00:00Added an answer on June 7, 2026 at 2:12 am

    After simplifying your self-answer:

    date_xf = easyxf(num_format_str='DD/MM/YYYY') # sets date format in Excel
    data = [list(n) for n in cursor.fetchall()]
    for row_index, row_contents in enumerate(data):
        for column_index, cell_value in enumerate(row_contents):
            if isinstance(cell_value, datetime.date):
                sheet1.write(row_index+1, column_index, cell_value, date_xf)
            else:
                sheet1.write(row_index+1, column_index, cell_value)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some search functionality that can return tens of thousands of results from
I have a form that shows results from a database query, these results can
I have two results from a data set. I want to add both results
I have a data frame consisting of results from multiple runs of an experiment,
I have need to return multiple results from a subquery and have been unable
I have some codes read the query results from sqlite: while (sqlite3_step(statement) == SQLITE_ROW)
Im trying to write the results from a SProc to a textfile. I have
I have a listview which loads its data from sqlite database. Each row in
I'm searching through some database search results on a website & trying to highlight
I'm trying to modify some code that returns results from the database. Currently the

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.