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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:26:43+00:00 2026-06-11T07:26:43+00:00

i am trying to format a date using Windows GetDateFormat API function: nResult =

  • 0

i am trying to format a date using Windows GetDateFormat API function:

nResult = GetDateFormat(
      localeId,   //0x409 for en-US, or LOCALE_USER_DEFAULT if you're not testing
      0,          //flags
      dt,         //a SYSTEMTIME structure
      "M/d/yyyy", //the format we require
      null,       //the output buffer to contain string (null for now while we get the length)
      0);         //the length of the output buffer (zero while we get the length)

Now we pass it a date/time:

SYSTEMTIME dt;
dt.wYear = 1600;
dt.wMonth = 12;
dt.wDay = 31;

In this case nResult returns zero:

The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
  • ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.

If, however, i return a date one day later:

SYSTEMTIME dt;
dt.wYear = 1601;
dt.wMonth = 1;
dt.wDay = 1;

Then it works.

What am i doing wrong? How do i format dates?

e.g. the date of the birth of Christ:

12/25/0000

or the date when the universe started:

-10/22/4004 6:00 PM

or the date Caesar died:

-3/15/44

Bonus Reading

  • Sorting It All Out: GetDateFormat is Gregorian based
  • GetDateFormatEx function
  • 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-11T07:26:45+00:00Added an answer on June 11, 2026 at 7:26 am

    This is actually a limitation on SystemTime.

    ...year/month/day/hour/minute/second/milliseconds value since 1 January 1601 00:00:00 UT... to 31 December 30827 23:59:59.999

    I spent some time looking up how to get around this limitation, but since GetDateFormat() takes a SystemTime you’ll probably have to bite the bullet and write your own format() method.

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

Sidebar

Related Questions

I am trying to output dates in the Italian format using date() as follows:
I'm trying to format a date in Rails 3 using the new syntax as
I am trying to format a date from an RSS feed using the following
I am trying to convert a string to proper date format using Java's SimpleDateFormat
When trying to get a string for the current date using DateFormat.getDateInstance().format(calendar.getTime()) it keeps
I am using MySQL DATE_FORMAT function to grab the date in the format i
I'm using date picker. I'm trying to change the format of date but I
I am trying to modify the date format displayed in a custom template using
In my application am trying to format and sort the date, i am using
I'm trying to convert given string in format 1899-12-30 19:00:00.000 to date using this

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.