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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:26:13+00:00 2026-06-05T09:26:13+00:00

Assuming the filename will always contain the date embedded within it, but that it

  • 0

Assuming the filename will always contain the date embedded within it, but that it won’t be uniform, is there a way to parse such and consistently convert the filename into a DateTime?

More specifically, if the filename always has the same format, such as:

“NNNNN.YYYY-MM-DD.log”

…this is pretty easy.

But, if the filenames can be in any of the following formats:

“NNN.YYYY-MM-DD.log” or
“NNNNN.YYYY-MM-DD.txt” or
“NNNNNNN.YYYY-MM-DD.bunyan”
— and maybe even:
“NNNNN.MM-DD-YYYY.xlw”
-and:
“NNNNN.YYYY-DD-MM.zsj”

— IOW, the filenames always contain the date represented in some fashion, but otherwise, all bets are off, is there hope, or nope?

  • 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-05T09:26:14+00:00Added an answer on June 5, 2026 at 9:26 am

    No, there’s no hope unless you can match an extension up to a known format.

    Some days/month combinations you’ll get lucky like 2012-12-31. Clearly, 31 isn’t the month value and you can deduce at least the day/month/4-digit year combo.

    As Alexei mentioned, a 2 digit year further complicates the problem.

    As a side note, this is pretty similar to a SQL Server problem. This is fine and dandy until it’s run with different date time format expectations:

    SELECT CAST('2012-05-01' AS DATETIME)

    Depending on the locale, this could be May 1, 2012 or January 5, 2012.
    (See this thread: Error converting string to datetime due to locale)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming that I know there is a git-daemon running at git://git.mycompany.com , how can
Assuming the file exists (using os.path.exists(filename) to first make sure that it does), how
assuming that I know the PID of a process and want to do a
Assuming that I have a CronTriggerBean similar to <bean id=midMonthCronTrigger class=org.springframework.scheduling.quartz.CronTriggerBean> <property name=jobDetail ref=reminderJobDetail
Assuming that best practices have been followed when designing a new database, how does
Assuming that I have a typedef declared in my .h file as such: typedef
In my situation I have a number of files that will be stored on
I'm wondering if there is a way to write MIPS assembly language file (just
I am working on a VPN dialer that will execute a login script when
Assuming that I have to write to a binary file. I can use 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.