Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Design

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 25-05-2007, 09:17 AM
cloudy's Avatar
New kid on the block
 
Join Date: May 2007
Location: malaysia
Posts: 8
Rep Power: 0
cloudy is on a distinguished road
Unhappy total days and half day calculation

hi, do u all know how to calculate the total days between 2 date? (start and end date) it can also caculate the half day(0.5) from the two date?means if the user wan take half day leave or 3 and half day leave.

i need help on it.plz..hope to hear from u all soon.urgent...

thanx.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 25-05-2007, 01:03 PM
genzy's Avatar
Nowhere Webmaster
 
Join Date: Aug 2006
Location: Malaysia
Posts: 1,581
Rep Power: 57
genzy is on a distinguished road
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 25-05-2007, 01:35 PM
iamfreelancer's Avatar
Vibrate your Brain Please
 
Join Date: Sep 2005
Location: in my body lar...
Posts: 1,244
Rep Power: 63
iamfreelancer will become famous soon enough iamfreelancer will become famous soon enough
Quote:
Originally Posted by cloudy View Post
hi, do u all know how to calculate the total days between 2 date? (start and end date) it can also caculate the half day(0.5) from the two date?means if the user wan take half day leave or 3 and half day leave.

i need help on it.plz..hope to hear from u all soon.urgent...

thanx.
what sort of scripting you are using.... pure javascript? php? ASP? .NET? or someother....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-06-2007, 09:57 AM
cloudy's Avatar
New kid on the block
 
Join Date: May 2007
Location: malaysia
Posts: 8
Rep Power: 0
cloudy is on a distinguished road
i m using pure ASP
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-06-2007, 01:47 PM
iamfreelancer's Avatar
Vibrate your Brain Please
 
Join Date: Sep 2005
Location: in my body lar...
Posts: 1,244
Rep Power: 63
iamfreelancer will become famous soon enough iamfreelancer will become famous soon enough
Quote:
Originally Posted by cloudy View Post
i m using pure ASP
datediff function will tell the days aparts and for half day maybe you calculate the hour apart. all this can be accomplish by using datediff...

for complete functionality of datediff please refer to w3school site -->>> VBScript DateDiff Function
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-06-2007, 01:54 PM
cloudy's Avatar
New kid on the block
 
Join Date: May 2007
Location: malaysia
Posts: 8
Rep Power: 0
cloudy is on a distinguished road
hi all, thanx alot.i think i solve the problem eoldi.thanx ya.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Total newbie here >_< Pip_X Website Programming 2 12-04-2006 01:12 PM
Total form looping textfield koisempoi Website Design 2 09-05-2005 12:35 PM
Whois: total domain hosted Filuren Paid Hosting Discussion Forum 12 08-10-2004 01:54 AM
Count total of records jeb23 Website Programming 17 04-02-2004 07:15 PM
PHP FrameWork For TOTAL NEWBIE bazet Website Programming 13 02-12-2002 04:19 PM



All times are GMT +8. The time now is 09:22 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59