#getting current time to in certain format for sql table

1 messages · Page 1 of 1 (latest)

hard ridge
#

Feel like this is strangely difficult for me to figure out. Trying to get current date and time in format yyyymmddhgmmsss and put into a sql column of type datetime. I’ve tried datetimeformatter but have had issues. Any suggestions?

mossy finchBOT
#

<@&987246584574140416> please have a look, thanks.

mossy finchBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

misty token
#

@hard ridge your JDBC driver can handle that conversion for you

#
        var now = LocalDateTime.now();
        var sqlTimestamp = Timestamp.valueOf(now);
        
        var nowAgain = sqlTimestamp.toLocalDateTime();
#

just convert your LocalDateTime to a sql timestamp

hard ridge
#

Ohh perfect. Thank you! And I can get rid of the semi colons directly in sql?

misty token
#

?

#

what

pearl pewter
hard ridge
misty token
#

but also what do you mean the semicolons?

pearl pewter
hard ridge
#

Sorry I meant colons and dashes 🤦‍♀️