# Thread: How to get the begin&end date of the current week

1. ## How to get the begin&end date of the current week

How to get the begin&amp;end date of the current week? For example: today is 2006-12-29 Friday. And I want to get the begin&amp;end date of this week. That is 2006-12-24 Sunday and 2006-12-30 Saturday. How to use WinRunner to implement it?Thanks in advance.

2. ## Re: How to get the begin&end date of the current week

Here is a short example on how you could do it:
<font class="small">Code:</font><hr /><pre>
static weekdays[] = {"Sun" = 0, "Mon" = 1, "Tue" = 2, "Wed" = 3, "Thu" = 4, "Fri" = 5, "Sat" = 6};

function getWeekdayStartEnd(in day, out StartDay, out EndDay)
{
auto initDate, arr[], startDate, endDate;
initDate=(date_string_to_Julian(day)-date_string_to_Julian("01/01/70"))*(60*60*24);
split(time_str(initDate), arr, " ");
startDate=(date_string_to_Julian(day)-weekdays[arr[1]]-date_string_to_Julian("01/01/70"))*(60*60*24);
endDate=(date_string_to_Julian(day)+(6-weekdays[arr[1]])-date_string_to_Julian("01/01/70"))*(60*60*24);
StartDay=time_str(startDate);
EndDay=time_str(endDate);
}
getWeekdayStartEnd("12/29/06", startOfWeek, endOfWeek);
</pre><hr />
Regards,
Juergen

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.