Reputation: 13
Using a datetime-local form field, and inserting its value into a SQL 2014 smalldatetime field. When querying the database to populate the form field for editing, I'm using
SELECT FORMAT(myDate, 'yyyy-MM-ddThh:mm:ss') AS myDate
My form field code is:
<input type="datetime-local" name="myDate"
id="myDate" required
value="<cfoutput>#myDate#</cfoutput>">
When populating the above form field with this database value, it returns the correct date and time BUT it always indicates AM. EXAMPLE: the value in the database table is
2016-11-03 13:09:00
but the value in the form shows as 11/03/2016 01:09 AM
How can I change my SQL format to accurately populate the form field? It should be 11/03/2016 01:09 PM?
Thanks
Upvotes: 0
Views: 2148
Reputation: 33571
I would leave the formatting in the front end. However, if you change the hours to uppercase it will give you the time in 24 hour format.
SELECT FORMAT(myDate, 'yyyy-MM-ddTHH:mm:ss') AS myDate
Upvotes: 2