我试图在OpenCart中从MySQL插入小时和分钟 相反,当我点击单独保存
时,将更新输入值更新为12:00 AM这是查询
$this->db->query("UPDATE " . DB_PREFIX . "delivery_time SET delivery_time_name = '" . $this->db->escape($data['delivery_time_name']) . "', delivery_time_from = 'TIME( STR_TO_DATE( " . $this->db->escape($data['delivery_time_from']) . ", \"%h:%i %p\" ) )', delivery_time_to = '" . $this->db->escape($data['delivery_time_to']) . "', status = '" . (int)$data['status'] . "' WHERE delivery_time_id = '" . (int)$delivery_time_id . "'");
但同样适用于phpmyadmin
UPDATE `oc_delivery_time` SET `delivery_time_name`="Slot2",`delivery_time_from`=TIME( STR_TO_DATE( "9:30 AM", "%h:%i %p" ) ),`delivery_time_to`=TIME( STR_TO_DATE( "12:00 PM", "%h:%i %p" ) ),`status`="1" WHERE `delivery_time_id`="2"
答案 0 :(得分:0)
答案 1 :(得分:0)
使用MySQL interval
或STR_TO_DATE('1:00 PM', ' %h:%i')+ interval 12 hour
Select STR_TO_DATE('1:00 PM', ' %h:%i')+ interval 12 hour
或尝试此查询: -
using System;
using System.Net;
using System.Runtime.InteropServices;
using System.Globalization;
using Microsoft.Win32;
namespace MyFirstAddIn
{
// Early binding. Doesn't need AutoDual.
[Guid("5E6CD676-553F-481E-9104-4701C4DAB272")]
[ComVisible(true)]
public interface IFinancialFunctions
{
double Bid(string symbol);
double Ask(string symbol);
double[,] BidnAsk(string symbol, string direction = null);
}
[Guid("B9B7A498-6F84-43EB-A50C-6D26B72895DA")]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public class FinancialFunctions : IFinancialFunctions
{
// Private class members.
private static readonly WebClient webClient = new WebClient();
private const string UrlTemplate = "http://finance.yahoo.com/d/quotes.csv?s={0}&f={1}";
// Private method - data download.
private static double GetDoubleDataFromYahoo(string symbol, string field)
{
string request = string.Format(UrlTemplate, symbol, field);
string rawData = webClient.DownloadString(request);
return double.Parse(rawData.Trim(), CultureInfo.InvariantCulture);
}
// Public "interface" methods.
public double Bid(string symbol)
{
return GetDoubleDataFromYahoo(symbol, "b3");
}
public double Ask(string symbol)
{
return GetDoubleDataFromYahoo(symbol, "b2");
}
public double[,] BidnAsk(string symbol, string direction = null)
{
double bid = GetDoubleDataFromYahoo(symbol, "b3");
double ask = GetDoubleDataFromYahoo(symbol, "b2");
return direction == "v" ? new[,]{{bid}, {ask}} : new[,]{{bid, ask}};
}
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type type)
{
Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type, "Programmable"));
RegistryKey key = Registry.ClassesRoot.OpenSubKey(GetSubKeyName(type, "InprocServer32"), true);
key.SetValue("",System.Environment.SystemDirectory + @"\mscoree.dll",RegistryValueKind.String);
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type type)
{
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(type, "Programmable"), false);
}
private static string GetSubKeyName(Type type, string subKeyName)
{
System.Text.StringBuilder s = new System.Text.StringBuilder();
s.Append(@"CLSID\{");
s.Append(type.GUID.ToString().ToUpper());
s.Append(@"}\");
s.Append(subKeyName);
return s.ToString();
}
}
}