![]() |
|
|
There are some inherent ASP date functions which are very powerful. They are very similar to the inherent SQL date functions bearing the same name, although the syntax varies slightly.
To get the current date, you can use the
To get the month, year, or day of any date, you can use the built in
functions
One of the most useful date functions is Let's look at a quick line of code which would create a date of 3/14/98 and store it in a variable name SomeDate: As you can probably see, DateSerial expects first the year, then the month, then the date. If we were to print out SomeDate, it would appear as "3/14/98" (or perhaps different, based on your machines regional settings). Now, for the real power with DateSerial. Let's say you want to make the variable SomeDate equal to the last day of the month two months ago from today. This could be a very tricky operation, because what if the current month was January, then you would have to go back a year. If the current month was April, you'd have to worry if it was a leap year or not. However, with DateSerial, none of these worries arise. Let's look at a line of code which will set SomeDate equal to the date described above: You may be furrowing your brow as you read this, but at least let me try to explain first. The DateSerial is forming a date for the current year (Year(Date)), for the month one month before the current month (i.e. the Month(Date) - 1, for the first day before the first day of the month (which is the last day of the month before the month before the current month. If that sentence doesn't have you confused, let me try once again.
The above syntax is giving you... The first day before the first day of the month before the month before the current month for the current year. If I didn't confuse you by now you are truly a wiz.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||