How to set default value of DateTime Struct?

I’m trying to set the default value of a DateTime Struct, but that’s not possible. The default default value is “0001.01.01-00.00.00” and if I change it to “2000.01.01-00.00.00” and hit Compile, it changes back to “0001.01.01-00.00.00”.
Unfortunately I also can’t find any node for directly setting the DateTime value.
I don’t care how, I just want to set this Date once to the date I need it to be, if you have any idea I would appreciate some hints how to do this

4.6.1, the last stable version


Which version are you working in?

So I have a similar experience as you do. During my time searching why that is I found this on AnswerHub where someone describes in a fashion how to manipulate DateTime

Hope it helps otherwise I would need to know what you would like to achieve by setting this to a higher value.


I know this way to manipulate the DateTime, but it does only work for short periods of time. I need to set my time to something like January 1. 1200, it’s a medieval game and I want to show the Date :slight_smile:

Hi John Alcatraz,

This issue just popped up in my list, so I’m not sure how it was overlooked but I apologize.

Testing this in 4.7.3, it appears to no longer be an issue. I’m able to set the default of a variable of type DateTime within the struct.

To update a struct value, use the “Set members in StructName” node, where “StructName” is the name of your structure. You can then get a reference to the Struct and set its DateTime member variable with a DateTime variable in the BP. Currently, there’s a bug in 4.7.3 that does crashes the editor if there’s a DateTime variable in a Blueprint, but it’s integrated into 4.7.4 (and should be available in the latest 4.7 branch if you’re building from GitHub).

Hope that helps!

You don’t have to apologize, I just moved this question to Bug Reports recently :wink:
Actually I don’t get what you want to say with “To update a struct value, use the “Set members in StructName” node, where “StructName” is the name of your structure”. There is no “Set members in DateTime” or am I blind?

I have no struct, why do you think I have a struct? I am just talking about a single DateTime variable, which is itself a struct. My question is how to set a single DateTime variable.

It will be the name of your struct instead of “DateTime.” So if your struct with the DateTime variable is named “DateTimeStruct,” you would search for the node called, “Set members in DateTimeStruct.” If you search only for “Set members in” in the context menu, you should see every struct in your project show up as an option and you can simply select the correct one.

It’s possible you’ll need to compile/save the struct again before it shows up in the menu. I’m not sure whether that’s a bug or I just forgot to do it, but that happened to me once. I’ll be looking into that separately.

I’m sorry, I was thrown off by your terminology. We usually refer to the DateTime Structure variables as DateTime variables, so I assumed you made a Struct using DateTime variables.

I’m looking into this now. The build I had from GitHub was old and the fix for the DateTime variable crash wasn’t included, so it’ll take a bit to build current. I’ll let you know how to set this up once I have everything up to date.

Okay, just double checked in the latest 4.7, and setting the default for a DateTime variable does work (it doesn’t reset when compiling), and having one in your BP no longer crashes the editor. As for setting one during runtime, it looks like that’s not actually possible. I’m going to enter a feature request for that, and I’ll let you know what the developers say when they get to it.

Unfortunately it is NOT fixed. I am using the 4.7 branch from github (some days old, 4.7.3 + 11 commits) and I can use DateTime variables without crashes. I set it to “1100.01.01-00.00.00” default value (medieval game). Then i start the game and print it out. And unfortunately I get " Aug 12, 1916" which is not very medieval.

Ah, okay, that looks like a separate issue. FDateTime isn’t correctly formatted by the string converter when using any dates before January 1st, 1970, so using the As Date Time nodes to print the DateTime variable won’t work for anything before then. The ICU based string formatter converts the FDateTime to a unix timestamp, which is then formatted as a string. January 1st 1970, is when the Unix epoch starts, thus the limitation.

I’ve entered a bug report for that (UE-13006) and I’ll let you know when I see an update. Thanks for the report!