Date and Time functions Articles
1: User entered date value validation in ASP
We can collect date values from user and check the inputs for a valid date or not by using IsDate () function. Here we will give the options to the user to select month, date and year from list boxes and text box and then create a date variable using it. Then we will check the date variable and find out it is a valid date or not.
2: Function IsDate to check valid date or date variable
We can check (or validate) the date variable or a date by using IsDate() function. User entered date values in a form are to be checked for correct date or not before further processing. This function takes one input and gives output as TRUE or FALSE based on the input.
3: Generating Date variables by using DateSerial function in ASP
By dateserial function in VBScript used in ASP we can generate date variable by using different variables for day, month and year. This is a quite useful as we can take different user input and create a date variable out of it. We can't create a date variable by placing the variables within two # marks. Like this
4: Getting Weekday names by using WeekDay and WeekDayName functions in ASP
From a date variable or from a date we can get the weekday number staring from Sunday as 1 and Saturday as 7 ( see the table at the end ) by using weekday() function. Here is the syntax of weekday function.
5: Getting Name of the Month by entering month number
We can get the months name by using the month number by using MonthName() function.
Here is the syntax for MonthName function.
6: Collecting parts of Date by using DatePart function
We can collect part of the date like year, month, day, date, Weekday etc from date by using DatePart function in VBScript used in ASP. We can extract the required date portion from the full date or date variable. Here is the syntax of the DatePart function.
7: Finding out difference in two dates by using DateDiff function
We can find out the difference between two dates by using DateDiff function of VBScript used in ASP. DateDiff() finds out the difference of the dates based on the required date part like month, year, days etc. Here is the basic syntax of DateDiff function.
8: DateAdd function to add date and time
We can add date by using DateAdd function of VBScript using in ASP. We can add any type of value like day, month , year etc using DateAdd function. Here is the syntax for the DateAdd function.
9: Display of date and time in local format in ASP using FormatDateTime
We can display Formatted date and time by using FormatDateTime function of VBScript within ASP. This function can take only date , only time or both date and time and display in specified format. Here is the format the function FormatDateTime uses.
10: Finding Today date and time and changing the format on location
In ASP using VBScript let us learn how to get present date, time in different formats. As we run ASP as a server side scripting process using VBScript as language, the time or date we will get is the time or date of the server. NOT THE LOCAL TIME OF THE CUMPUTER we are using to access the page
Page 1 of 1
[1]