Source language: Translate to:

Determine Week of the Year

Questions about NeoBook PlugIns

Moderator: Neosoft Support

Determine Week of the Year

Postby datadon » Thu Dec 29, 2011 10:10 am

Anybody know of a way to determine what the week of the year (1 thru 52) is from the current date?

Plugin or otherwise.

Thanks
Don

'If you want to get a brontosaurus from 'a' to 'b' then you ride the dinosaur - you don't carry it!'
User avatar
datadon
 
Posts: 389
Joined: Sun Apr 03, 2005 7:55 pm
Location: Lorena Texas

Postby dec » Thu Dec 29, 2011 10:15 am

Hi,

I can add this action for you (and others) to my npUtil plugin Donald.

Just give me some time. ;)
Last edited by dec on Thu Dec 29, 2011 11:17 am, edited 3 times in total.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Postby dec » Thu Dec 29, 2011 11:13 am

Hi Donald,

Just take a look at the new npUtil npWeeksInAYear and npWeeksInAYear actions.

With the second one you can write something like this to get the week of the current date:

Code: Select all
.Encode the datetime value to match the current datetime
npEncodeDate "[Year]" "[MonthNum]" "[DayNum]" "[DateTime]"

.Use the encoded datetime to get the week of the year
npWeekOfTheYear "[DateTime]" "[Result]"


Hope can be useful for you. ;)
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Postby datadon » Thu Dec 29, 2011 12:07 pm

Yes! That should do it nicely. I was going to see if it was available anywhere else before approaching you on this, but you jumped right in and gotter done!

Thanks so much David.

Let me throw a bone out there,

David makes great plugins! And his follow up support is excellent.

I use his plugins daily.

Don
Don

'If you want to get a brontosaurus from 'a' to 'b' then you ride the dinosaur - you don't carry it!'
User avatar
datadon
 
Posts: 389
Joined: Sun Apr 03, 2005 7:55 pm
Location: Lorena Texas

Postby dec » Thu Dec 29, 2011 12:10 pm

Thanks Don! :oops:
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Postby datadon » Thu Dec 29, 2011 12:21 pm

Thought I might explain why I wanted this for others as a reference of use. I have a pub that writes a daily report for me. Each entry has dates, info etc. It saves/appends the info to a csv file that can be viewed in Excel or NB. I wanted a way to group them together by week so I can produce a weekly list for the weekly report. So now I have it. I just apply the week of the year number to each entry based on the current or selected date and I can go back and get the data for that specific week.
Don

'If you want to get a brontosaurus from 'a' to 'b' then you ride the dinosaur - you don't carry it!'
User avatar
datadon
 
Posts: 389
Joined: Sun Apr 03, 2005 7:55 pm
Location: Lorena Texas

Postby dpayer » Thu Dec 29, 2011 2:30 pm

datadon wrote:Thought I might explain why I wanted this for others as a reference of use. I have a pub that writes a daily report for me. Each entry has dates, info etc. It saves/appends the info to a csv file that can be viewed in Excel or NB. I wanted a way to group them together by week so I can produce a weekly list for the weekly report. So now I have it. I just apply the week of the year number to each entry based on the current or selected date and I can go back and get the data for that specific week.


Curious,

If the year starts on a Wednesday, 7 days later it is a Tuesday. Is that Tuesday in the first week of the year, or the second week?

Are you counting by Sundays?

Here is something that told me this is the 52nd week of the year:
Code: Select all
DateToNum "[Year]/1/1" "y/m/d" "[Jan1Number]"
DateToNum "[DateShort]" "m/d/y" "[TodayNum]"
Math "(([TodayNum] - [Jan1Number])/7)" "0" "[weeknumber]"

If counting by Sundays, you would need to find out what day of the week Jan 1 was on and then add the requisite number to get to the first Sunday and use that as the [Jan1Number].

AlertBox "test" "this is week # [weeknumber]"


David
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby TechMediaPlugins2010 » Fri Dec 30, 2011 3:46 am

Don, my tmDates have this functions and a lot more
Advanced Plugins for NeoBook
www.techmedia-plugins.com.br
TechMediaPlugins2010
 
Posts: 298
Joined: Wed Jun 23, 2010 1:45 pm
Location: Rio de Janeiro - Brazil

Postby datadon » Fri Dec 30, 2011 7:34 am

Dpayer (lots of Davids here)

Not sure I can answer that. I know the DEC used a control that has various date functions available and this was one of them (correct me if I am wrong DEC) . It is built in as they say. For me it is not that critical. As long as I can associate my entries with a weekly number, be it 52 or even 53, I am good with it. It may be more critical to others.
Don

'If you want to get a brontosaurus from 'a' to 'b' then you ride the dinosaur - you don't carry it!'
User avatar
datadon
 
Posts: 389
Joined: Sun Apr 03, 2005 7:55 pm
Location: Lorena Texas

Postby dec » Fri Dec 30, 2011 7:47 am

datadon wrote:Dpayer (lots of Davids here)

Not sure I can answer that. I know the DEC used a control that has various date functions available and this was one of them (correct me if I am wrong DEC) . It is built in as they say. For me it is not that critical. As long as I can associate my entries with a weekly number, be it 52 or even 53, I am good with it. It may be more critical to others.


Exactly on this case I use the WeekOfTheYear function built in the environment I use to develop the plugins.

Click the link for more information about the refered function. I copy some of this onto the plugin action help too.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain


Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 1 guest