PC Tools > Scripting Home > Code Snippets > Date & Time Functions
http://www.pctools.com/guides/script...?act=reference
Based on the article below, to calculate the half day in the hourly unit could be:
hours = DateDiff("h", "1-Jan-2007", "2-Jan-2007") / 2
"h" represents hour (refer to the below table)
You may try to play around.
DateDiff() - Calculate the Difference Between Two Dates
http://www.pctools.com/guides/script...?act=reference
Quote:
Description
The DateDiff() function is used to compare two dates and calculate the period between them in days, months, years, hours, minutes or seconds.
DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]])
Parameters
The interval is a string expression representing the type of interval to increase or decrease the date by. See the table below for possible values:
<%font_body%>Value <%font_body%>Description
<%font_body%>d <%font_body%>Day
<%font_body%>m <%font_body%>Month
<%font_body%>yyyy <%font_body%>Year
<%font_body%>w <%font_body%>Weekday
<%font_body%>y <%font_body%>Day of year
<%font_body%>ww <%font_body%>Week of year
<%font_body%>q <%font_body%>Quarter
<%font_body%>h <%font_body%>Hour
<%font_body%>n <%font_body%>Minute
<%font_body%>s <%font_body%>Second
The date1 and date2 parameters are used to specify the initial and final dates for comparison.
The optional parameter firstdayofweek specifies the [id=44#days]day of the week[/id] to use as the first day. If not specified, Sunday is the default value.
The optional firstweekofyear parameter specific the how the [id=44#weeks]first week of the year[/id] is defined.
Examples
If you where born on April 1st, 1964 you could calculate you age in days using the following function:
DaysOld = DateDiff("d", "1-Apr-64", Now)
You could calculate the number of seconds since New Years Day using this example:
SecondsNYD = DateDiff("s", "1-Jan-" & Year(Now), Now)
|