[AccessD] MySQL / VBA Now() format

Stuart McLachlan stuart at lexacorp.com.pg
Tue Jan 24 16:29:49 CST 2023


Hmm, This works for me:

Sub Test()
Dim sSQL As String
sSQL = "Update tblApplicants set LastWebUpdate = Now() where ApplPK = 1"
CurrentDb.Execute sSQL
End Sub

 tblApplicants.Description is
ODBC;DRIVER={MySQL ODBC 8.0 Unicode 
Driver};UID=xxxxx;DFLT_BIGINT_BIND_STR=1;PORT=3306;DATABASE=xxxxx;SERVER
=localhost;PASSWORD=xxxxx;;TABLE=tblapplicants

And MySQL 5.7.40 is running on localhost.


That said, this also works for me:
sSQL = "Update tblApplicants set LastWebUpdate = '" & Format$(Now(), "yyyy-mm-dd 
hh:nn:ss") & "' where ApplPK = 1"


JUST NOTICED BELOW!
You were using "yyyy-mm-dd HH:mm:ss"

try changing HH-mm to hh-nn :)




On 24 Jan 2023 at 19:01, kost36 at gmail.com wrote:

> Hi Stuart,
> It was the first I tried but doesn't work for me
> /kostas
> 
> -----Original Message-----
> From: AccessD <accessd-bounces+kost36=gmail.com at databaseadvisors.com>
> On Behalf Of Stuart McLachlan Sent: Tuesday, January 24, 2023 2:31 AM
> To: Access Developers discussion and problem solving
> <accessd at databaseadvisors.com> Subject: Re: [AccessD] MySQL / VBA
> Now() format
> 
> I just use a plain:
> sSQL = .......... , Now() as dtg, .....
> 
> and it works fine  for updating a Timestamp with MySQL ODBC Driver
> 8.0.0.
> 
> -- 
> Stuart
> 
> 
> On 23 Jan 2023 at 21:20, kost36 at gmail.com wrote:
> 
> > Hey all,
> > I use a MySQL table connected to an access form via ODBC driver
> > (8.0.3) and I have a problem saving a timestamp field. The record in
> > MySQL is "yyyy-mm-dd HH:mm:ss" Based on my pc regional settings ms
> > access shows it as "dd-mm-yyyy HH:mm:ss". I use Format(Now(),
> > "yyyy-mm-dd HH:mm:ss") but it doesn't make any change. Am I missing
> > something ? Thank's
> > 
> > -- 
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> > 
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list