Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > Visual Studio 2005
|
Visual Studio 2005 For discussing Visual Studio 2005. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2009, 12:17 AM
Authorized User
 
Join Date: Mar 2009
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
Default Function like DateAdd and Datediff in javascript

Hi All,
Can any one tell me ,if there is any function like datediff or dateadd in javascript


Thank you in Advance

Pratik Asthana
 
Old April 2nd, 2009, 08:55 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

First, Google is a great reference, use it (both links below I snagged from google in < 30s).

As far as Datediff goes, VB.NET has a DateDiff function C# doesn't.

VB.NET: http://blogs.msdn.com/vbfaq/ (about half way down)
C#: http://www.c-sharpcorner.com/UploadF...iff_CS_DC.aspx

As far as dateadd goes you can use functions similar to:
DateTime.Now.AddDays(1);
DateTime.Now.AddYears(2);

And so on.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old April 2nd, 2009, 09:09 AM
Authorized User
 
Join Date: Mar 2009
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,
Thanks for Reply
but I need this in javascript
 
Old April 2nd, 2009, 09:14 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Then why did you post in a Visual Studio forum as opposed to a JavaScript forum? In any event:

JavaScript Date functions: http://www.w3schools.com/jsref/jsref_obj_date.asp

JavaScript doesn't have a built in DateDiff function so you need something similar to this: http://javascript.internet.com/math-...ifference.html

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use the datediff function to compare dates cesemj VB How-To 0 June 9th, 2006 04:03 PM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
dateadd function help iswo Beginning VB 6 1 August 22nd, 2005 12:07 PM
DateAdd function.. arshad mahmood VB Databases Basics 1 July 29th, 2003 07:37 AM
datediff function mAdg3rr Classic ASP Databases 2 July 26th, 2003 10:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.