Click here to Skip to main content
16,009,068 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

Can any body help me how to get only date part from 'mm/dd/yyyy 12:00 AM' in javascript.

ex: I have '01/20/2010 12:00 AM' i need to get only unto '01/20/2010' into a variable. this is the value i'm getting from database.

Thanks in advance,
Mohan
Posted

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
==================================
 
Share this answer
 
v2
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.
 
Share this answer
 
hi,

you can change format of the date in SQL as below
SQL
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900