.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

How to do a date calculation?

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :C#

SharePoint 2007 :

I have a list with 2 custom columns (Creator, Checker) that contains name, date & time they respond and a third column (Duration) that is calculated field, as below:

1) Creator - domain\ledasaa 12/04/2011 12:05 --> text format

2) Checker - domain\ledasaa 13/04/2011 12:05 --> text format

3) Duration --> number format

I wanted to calculate the difference between the first 2 columns and show it in the  3rd field.

So what is the calculation? because this 2 field is text format? Please assits.. Thanks in advance

View Complete Post

More Related Resource Links

Running sum calculation based off date dimension?

I have a fairly simple calculated measure which does a running sum of a particular measure : --This does a running sum of the Net Measure up until the previous date (basically a "Starting Count" for a period. Sum(PeriodsToDate([Change Date].[Year - Month - Date].Levels(0), [Change Date].[Year - Month - Date].PrevMember), [Measures].[Net]) The problem is I have added a second hierarchy in the date dimension that includes quarter called [Year - Quarter - Month - Date]. Is there anyway around not having to create a seperate running sum calculated measure to use this new hierarchy? The PrevMember in the initial calculated measure works, although it reports the wrong number when used in conjunction with the Quarter hierarchy because it gets the PrevMember in the other hierarchy. What is the best practice for this situation?Craig

Sql Server and Access Date Calculation


Hi Everybody,


We are working on same Sql Server and Access database tables. All columns and values same. But When I run query on sql and access, access and sql return different values to me.

Access Sql Query:

Int(Now())-[myDateColumn])/30 = 23.986760875771


Sql Server Query

(CONVERT(INT,GETDATE()) - CONVERT(INT,[myDateColumn])) / 30.0 = 24.033333


Why different values??


Thank you.



help with date additions and calculation within a store procedure


is there a function for adding days to a date value within a stored procedure?

If I had a field with a start date and a field for duration which would be how many days the even  lasts....

like if I wanted something like this:

.... TableName.StartDate, DateAdd(TableName.StartDate, TableName.Duration) as EndDate, etc.....



Age Calculation On Entering Date Of Birth



I want to Calculate The Age On Client Entering The Date Of Birth

If User Are Below Age 18 then PopMessgae Show !

You can not register

Thanks Regards

Samarth Patel



Date calculation questions


I need to write a query or function to calculate a shift code.  The shift schedule is crazy and I am not sure how to approach this.  Currently the shift schedule is 4 on / 4 off and I have the following TSQL to calculate that and it works fine.


DECLARE @sod int --shift offset day/night
DECLARE @currentHour int
SET @sod =

Life to Date calculation MDX



I have a Time dimension that includes a Hierarchy with Year and Week attributes, I would like to sum up all weeks from the current member to the first member of the week dimension to get a life to date value. I cannot seem to find the correct MDX function to get the correct data ro return.

Your help would be greatly appreciated.


Date Difference Calculation


Hi there,

I have 2 date columns as follows:

Due Date Submission Date
31-Jan-2010 30-Jan-2010
16-Mar-2010 20-Mar-2010

now based on the above 2 dates i need to create an sproc for generating the following table with the given validation


Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

How To Set a Date Format In GridView Using ASP.NET 2.0

A very common desire is to set a column of a gridview to display just the month, day and year of a DateTime type. The problem is the by default, the HtmlEncode property of the boundfield attribute (
The problem is that if this field is enabled, you can not pass format information to the boundfield control. That is, if you try the following code, you will not get the desired result.

jQuery Date picker Implementation in ASP.NET

I've posted a wrapper ASP.NET around the jQuery.UI Datepickercontrol. This small client side calendar control is compact, looks nice and is very easy to use and I've added it some time back to my control library.

This is primarily an update for the jQuery.ui version, and so I spend a few hours or so cleaning it up which wasn't as easy as it could have been since the API has changed quite drastically from Marc's original implementation. The biggest changes have to do with the theming integration and the resulting explosion of related resources.

If you want to use this component you can check it out a sample and the code here:

How to format datetime & date with century?

Execute the following Microsoft SQL Server T-SQL datetime, date and time formatting scripts in Management Studio Query Editor to demonstrate the usage of the multitude of temporal data formats available and the application of date / datetime functions.


Date and Time Functions in SQLSERVER

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

1 DATEPART Function
2 DATENAME Function
3 DAY, MONTH, and YEAR Functions
5 DATEADD Functions
6 DATEDIFF Function
7 More SQL Server Functions

Data Types - Date and Time in SqlServer

Date and time values can be stored with either the DATETIME or SMALLDATETIME data type. The difference between the two is that SMALLDATETIME supports a smaller range of dates and does not give the same level of precision when accounting for time. The DATETIME data type can hold values from January 1st of 1753 to December 31st of 9999. The time is stored to the 1 three hundredths of a second and each value takes up 8 bytes of storage. The SMALLDATETIME data type can hold values between January 1st 1900 and June 6th of 2079. The time is tracked to the minute and each value takes up 4 bytes of storage. The majority of business applications can live happily with SMALLDATETIME, however, if you are in an environment where each second matters or you need to make estimates to the distant future (or past) then you have to resort to DATETIME. If you fail to specify the time when inserting a value into a DATETIME or SMALLDATETIME column, a default of midnight is used. If you fail to specify the date portion the default of January 1, 1900 is used.


How to calculate childs age,but when i enter childs age as '03/27/2007' it returns 3 years where as actual age is 2 yr 11 months

Built-in Functions - Date and Time Functions

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

Essential SQL Server Date, Time and DateTime Functions

The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all.

Date/Time Conversions Using SQL Server

There are many instances when dates and times don't show up at your doorstep in the format you'd like it to be, nor does the output of a query fit the needs of the people viewing it. One option is to format the data in the application itself. Another option is to use the built-in functions SQL Server provides to format the date string for you.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend