如何仅从"mm/dd/yyyy 12:00 AM"获取日期部分 [英] How to get only date part from 'mm/dd/yyyy 12:00 AM'

查看:194
本文介绍了如何仅从"mm/dd/yyyy 12:00 AM"获取日期部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

任何机构都可以帮助我如何从javascript中的"mm/dd/yyyy 12:00 AM"获取日期部分.

例如:我有"01/20/2010 12:00 AM",我只需要将"01/20/2010"变成一个变量.这就是我从数据库中获得的价值.

预先感谢,
Mohan

解决方案

请参见此处 [ ^ ].

======详细信息==========

将您获取的日期指定为javasciprt日期.

var myDate = new Date(''01/20/2010 12:00 AM'');
myDate.format("mm/dd/yy");



那应该做.

桑迪普
=================================从数据库,并需要将其转换为日期?如果它来自数据库,为什么不返回月,日和年作为单独的值,并根据这些值建立日期?

如果您使用datetime类型,而只想存储一个日期,那么答案就是总是使用同一时间,并在UI代码中忽略它.


hi,

您可以按以下方式在SQL中更改日期的格式

 选择 转换(> nvarchar ( 30 ),GETDATE(), 101 ) 解决方案 

See here[^].

====== Further details ==========

Assign the date you got into javasciprt date.

var myDate = new Date(''01/20/2010 12:00 AM'');
myDate.format("mm/dd/yy");



That should do.

Sandeep
==================================


You''re getting that from the db and need to turn it into a date ? If it''s coming from the db, why not return month, day and year as seperate values and build a date from those ?

If you have a datetime type and you only want to store a date, the answer is to always use the same time, and ignore it in your UI code.


hi,

you can change format of the date in SQL as below

SELECT CONVERT(nvarchar(30),GETDATE(),101) AS ServerDate


here change the 3rd parameter value 100-114, you can get different formats.

SQL Server have several formats in CONVERT function & you can search google for details


这篇关于如何仅从"mm/dd/yyyy 12:00 AM"获取日期部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆