Announcement

Collapse
No announcement yet.

Format date time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Format date time

    I would like to format the date time as '2017-05-16 17:05:41' for mysql field.

    I have a dateinfo defined as

    dim dateinfo as date
    dateinfo = NOW()

    INSERT INTO history(date,time,code,type,name,value,location,location2,In sertDate) VALUES('" & sdate & "','" & stime & "','" & dev_address & "','" & device_type & "','" & device_name & "','" & device_value & "','" & device_location & "','" & device_location2 & "','" & DateInfo "')

    Unfortunately I get an error "Error in saving to Database. Error is :Incorrect datetime value: '5/18/2017 10:32:35 AM' for column 'insertdate' at row 1"

    How do I format it to be as '2017-05-16 17:05:41'

    Aldo

    #2
    For an Oracle insert I use:
    to_Date('" & System.DateTime.Now & "','MM/DD/YYYY HH:MI:SS PM')

    Here's a site that shows the mySql equivalent.
    http://www.sqlines.com/oracle-to-mysql/to_date
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment

    Working...
    X