Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

Hard to fill in DateTime fields

w00kie's profile image w00kie posted 2 months ago in General Permalink

For DateTime fields, I want to be able to default to the current DateTime, or enter something like NOW() when editing a row. I found this issue which discusses a setting to handle this:

https://www.heidisql.com/forum.php?t=10103

However, this says that it only works with NULLs. If I duplicate a row that already had a value and then make it blank, I get 0000-00-00 00:00:00 in the DateTime field.

ansgar's profile image ansgar posted 2 months ago Permalink

You can press Ctrl/F2 to go into function mode in a cell, or rightclick > Insert value > SQL function:

Description

That lets you write any SQL function like NOW() or whatever into the field.

Alternatively, in the same menu, there is a "Date and time" item with the current time to click on.

ansgar's profile image ansgar posted 2 months ago Permalink

Another thing you might not have enabled is this one:

Description

This sets the current time into an edited field if it's null.

Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.
w00kie's profile image w00kie posted 2 months ago Permalink

Thanks! Ctrl/F2 did the trick. And I guess I didn't look in the menus very well-- I was looking for something like Insert Value > Date and time, but must have missed it!

I did have the prefill empty date/time fields with current date/time enabled, however, it seems like this only works with NULLs. If I duplicate a row that already had a value and then make it blank, I get 0000-00-00 00:00:00 in the DateTime field.

ansgar's profile image ansgar posted 2 months ago Permalink

Ctrl/Shift/N assigns NULL to a grid cell. Perhaps that field was not NULL before you entered it.

w00kie's profile image w00kie posted 2 months ago Permalink

Yes, you're correct. It wasn't NULL. I feel like this is less intuitive than being able to copy a row and then conveniently enter NOW() before setting it to NULL. However, now that I know what you just mentioned to me, it's actually not so hard.

Please login to leave a reply, or register at first.