首页 \ 问答 \ 如何更改db [php]中存储的日期格式?(How to change format of date from that stored in db [php]?)

如何更改db [php]中存储的日期格式?(How to change format of date from that stored in db [php]?)

我将日期时间存储在数据库中为$date=date("Ymd H:i:s"); 现在在大多数地方我使用的格式与存储的格式相同2016-03-01 19:04:18 ,但在一个地方我更喜欢输出为3月01日19:04如何更改输出格式从数据库2016-03-01 19:04:183月1日19:04


I am storing date time in database as $date=date("Y-m-d H:i:s"); Now on most places I use it in the same format as it is stored 2016-03-01 19:04:18, but on one place I would rather prefer output to be March 01 at 19:04 how can I change format of output from database from 2016-03-01 19:04:18 to March 01 at 19:04.


原文:https://stackoverflow.com/questions/35744559
更新时间:2023-11-12 17:11

最满意答案

您必须将isnull应用于列,而不是整个查询。

试试下面的内容

select ISNULL(LeaveApply_Id,0) AS ID from Tbl_Stud_Leave_Apply 
where Candidate_Id= @Candidate and (@date between Stud_LeaveFromDate and Stud_LeaveToDate)

在上面的@Candidate@date被动态传递给查询。


You have to apply the isnull to the column, not to the whole query.

Try the below

select ISNULL(LeaveApply_Id,0) AS ID from Tbl_Stud_Leave_Apply 
where Candidate_Id= @Candidate and (@date between Stud_LeaveFromDate and Stud_LeaveToDate)

In the above @Candidate and @date are dynamically passed to query.

相关问答

更多
  • 您必须将isnull应用于列,而不是整个查询。 试试下面的内容 select ISNULL(LeaveApply_Id,0) AS ID from Tbl_Stud_Leave_Apply where Candidate_Id= @Candidate and (@date between Stud_LeaveFromDate and Stud_LeaveToDate) 在上面的@Candidate和@date被动态传递给查询。 You have to apply the isnull to the co ...
  • 与某些编程语言不同,您不能指望 T-SQL WHERE子句中的短路 。 它可能会发生,也可能不会发生 。 Unlike in some programming languages, you cannot count on short-circuiting in T-SQL WHERE clauses. It might happen, or it might not.
  • 以下将起作用 - 您不必在HAVING子句中指定聚合 SELECT dept, SUM (salary) FROM employee GROUP BY dept HAVING dept = "HR" or SUM (salary) > 25000 但你的声明“支付超过25000的所有员工”并不清楚。 你要吗 所有员工每人收入超过25000的部门,或所有员工总共收入超过25000的部门? 上面的查询为您提供了第二个选项,因为它最接近您的原始查询 The below will work - you do ...
  • 如有疑问,请阅读文档 : <=>是一个NULL安全相等的。 此运算符执行与=运算符类似的相等比较,但如果两个操作数均为NULL,则返回1而不是NULL;如果一个操作数为NULL,则返回0而不是NULL。 When in doubt, read the documentation: <=> is a NULL-safe equal. This operator performs an equality comparison like the = operator, but returns 1 rather t ...
  • 在你的“B”表中包裹一个OR ,比如: AND (len(searchString)=0 OR table_b.column_b LIKE "%searchString%" ) 这样,如果字符串没有值,则其长度将为零,并且OR的第一部分将被评估,总是返回为真,并将该部分的等式返回为有效,并使用LIKE子句忽略另一半。 您可以根据需要应用相同的链接表。 Wrap an OR around your "B" table, such as: AND (len(searchString)=0 OR table_b ...
  • “OR只评估表达式,直到找到TRUE结果为止” 它只需要,但这不是你的问题(实际上这是在原始情况下拯救你的东西)。 你的两个查询并不是真正等同的。 我认为你在Column2中有NULL ,它永远不会导致(Column2 LIKE ISNULL(@Param2, '') + '%')为真 - 在原始版本中, @Param2 = ''掩盖了这种情况,因为它是真的(有时) 也许: (ISNULL(Column2, '') LIKE ISNULL(@Param2, '') + '%') 记住NULL的三值逻辑: ...
  • 这是因为null = null始终为false用于null的运算符是IS或IS NOT您可以使用下面的查询来获得期望的输出 SELECT n FROM Nums WHERE n IN (1,2) OR n IS NULL [编辑] Thanx @Buckwad OK I have found the answer SELECT n FROM Nums WHERE n NOT IN (1, 2, null) evaluates to SELECT n FROM Nums n!=1 AND n! ...
  • select * from table where COALESCE(IsDeleted, 0) <> 1 -- or ISNULL instead of COALESCE. --ISNULL seems to be better in subqueries, but it's not ANSI SQL. 要么 select * from table where IsDeleted <> 1 or IsDeleted IS NULL select * from table where COAL ...
  • 做这个: WHERE Name LIKE '%' + @nameparam + '%'"; Do this: WHERE Name LIKE '%' + @nameparam + '%'";
  • 您的where子句限制Nation表中的项目,但不限制Customers表。 或者,以另一种方式查看,子查询选择正确的行,但之后您已向查询(Customers)添加了一个没有限制的新表。 解决这个问题的正确方法不是使用IN运算符,而是使用JOIN运算符。 使用customer表中的nation键将两个表连接在一起。 你没有给我们所有的列名,所以我将不得不猜测国家的关键。 SELECT c.C_ID, c.C_NAME, n.N_NAME FROM customers c INNER JOIN nation ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)