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

Top 5 Contributors of the Month
Post New Web Links

ASP Date Function

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :Windows Application


I'm having troubling converting my asp date code to vb can someone help me.

<% date_value = date() %>
<%= date_value %><br>
<% dayofweek=weekday(date_value) %>
day number in week <%= dayofweek %>
<% select case dayofweek %>
<% case "1" %>
<% case "2" %>
<% case "3" %>
<% case "4" %>
<% case "5" %>
<% case "6" %>
<% case "7" %>
<% end select %>



View Complete Post

More Related Resource Links

How to Date function convert (09/13/2010 10:18:24 to 13.Sep.10)

 How to Date function convert (09/13/2010 10:18:24  to     13.Sep.10)passing a simple query no template used input  09/13/2010 10:18:24output 13.Sep.10

several date ranges in one report - first/last function?



    I´m working on a report with SSRS 2008 which is meant to show a lot of figures aggregated for the whole calendar year. In all datasets I have the date as a parameter (date with hierarchy: year - month). So to get the sums for the whole calendar year I only have to select all the months of the wanted year and SSRS shows the total for that period. That works fine. The problem:

Some figures (for which separate datasets are used) are not meant to be aggregated, eg the number of open cases at the beginning of the period or the number of open cases at the end of the period.

I tried using the First/Last-functions on that figures but that doesn´t work because the first/last function doesn´t seem to refer to the date-parameter but to other dimensions (in my case: region because it shows the summed up values for the first region instead of the not-aggregated values for the first month).

How can I acchieve that my report shows the first/last value dependent on the choosen date-parameters while summing up the other values for the whole choosen date-parameters?


Your help would be much appreciated.



Date Conversion in Function


I have a date conversion in a function that is failing to convert.

this fails when trying to convert

This uses a function to convert the date to a string



Error -

Conversion failed when converting datetime from character string.

below is the code for the functin




-- Replace Year


	SET @pos = CHARINDEX('yyyy', @format)

	WHILE @pos > 0


		SET @format = STUFF(@format, @pos, 4, DATENAME(yyyy, @date))

		--PRINT @format

		SET @pos = CHARINDEX('yyyy', @format)



	SET @pos = CHARINDEX('yy', @format)

	WHILE @pos > 0


		SET @format = STUFF(@format, @pos, 2, RIGHT(DATENAME(yyyy, @date) ,2))

		--PRINT @format

		SET @pos = CHARINDEX('yy', @format)



-- Replace Month


	SET @pos = CHARINDEX('mmmm', @format)

	WHILE @pos > 0


		SET @format = STUFF(@format, @pos, 4, DATENAME(month, @date))

		--PRINT @format

		SET @pos = CHARINDEX('mmmm', @format)



	SET @pos = CHARINDEX('mmm', @format)

	WHILE @pos > 0


		SET @format = STUFF(@format, @pos

Whether Date & Math function supported in WCF Data service



Whether Data(day,year,hour,minute,month,second) and Math functions(double round, decimal round, double floor, decimal floor, double ceiling, decimal ceiling) are supported in WCF data service using ODATA.

Thank You Benita Blas

convert date function


I'm trying to convert the date function below in VB to C#:

db.DatePosted = CDate(Now()).ToString("ddd MM/dd/yyyy")

The following C# was suggested on a site...

db.DatePosted = String.Format(“{0:ddd MM/dd/yyyy}”,DateTime.Now);

...but gives a bunch of errors:

Only assignment, call, increment, decrement, and new object expressions can be used as a statement
The type or namespace name 'ddd' could not be found (are you missing a using directive or an assembly reference?)
The name 'dd' does not exist in the current context
The name 'yyyy' does not exist in the current context

What would be the correct syntax?

function to calculate number of business days in a month for a given date


hi ,

Is there any function to calculate number of business days in a month for a particular date.  my input would be just a single date



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.

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.

Date and Time Data Types and Functions

The following sections in this topic provide an overview of all Transact-SQL date and time data types and functions. For information and examples that are common to date and time data types and functions

SQL Server Date Formats

One of the most frequently asked questions in SQL Server forums is how to format a datetime value or column into a specific date format. Here's a summary of the different date formats that come standard in SQL Server as part of the CONVERT function. Following the standard date formats are some extended date formats that are often asked by SQL Server developers.
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