Day number instead of formatted date?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Day number instead of formatted date?

Post by Me_again » Wed Feb 16, 2005 4:57 pm

Is there a way to get a day number instead of a formatted date - without calculating it out from the m/d/y ? Maybe in vbscript?

I need to generate text in a different color on alternate days, maybe someone has a better idea how to do that without looking for odd/even day numbers?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Feb 16, 2005 5:22 pm

Yes, just use the Day function:

Day>result

Returns the current day number of the month in the specified variable.
MJT Net Support
[email protected]

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Feb 16, 2005 5:29 pm

Day>variable to get day number
===========================

Using Odd/Even will not work because of months with odd numbered days.

Using +1 and -1 works in many cases for toggling just by multiplying current value * -1. So -1 becomes +1 and +1 becomes -1, etc.

Code: Select all

Let>Status=1
Label>Toggle
IF>%Status%=1,Color1,Color2

Label>Color1
Do stuff for color1
Goto>More

Label>Color2
Do stuff for color2
Goto>More

Label>More
IF>Conditions for Done,StopToggle
Let>Status=%Status%*-1
Goto>Toggle

LAbel>StopToggle
Do stuff.....
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Feb 16, 2005 6:07 pm

I was thinking of a day serial number since some long ago day, like the date in excel.

Toggling's a good idea but it really is date/day dependent. This thing runs each hour and populates a table with fixed locations for the time. For example today's 9:00 AM value overwrites yesterday's 9:00 AM value, but until 10:00 AM the next entry in the table is from yesterday (don't shoot me I didn't invent the format) and it needs a way to highlight that it's not today's data for folks who just scan the table and have a poor sense of time.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Feb 16, 2005 6:16 pm

How about the date in Julian form:
http://www.mjtnet.com/forum/viewtopic.php?t=1463

Does that help?

Or to get a unique number based on the time/date just do:

Year>yy
Month>mm
Day>dd
Hour>hh
Min>m
Sec>s
Let>tval=%yy%%mm%%dd%%hh%%m%%s%
MJT Net Support
[email protected]

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Feb 16, 2005 6:37 pm

Julian date is just what I need :D

The code in that example returns a low number = 5047, and I think it should be 2453418

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Feb 16, 2005 6:52 pm

Hmm, I think that must be a different Julian date. This one makes more sense:


VBSTART
Function MyJulian
y=Year(Now)
m=Month(Now)
d=Day(Now)
MyJulian = ( 1461 * ( y + 4800 + ( m - 14 ) / 12 ) ) / 4 + _
( 367 * ( m - 2 - 12 * ( ( m - 14 ) / 12 ) ) ) / 12 - _
( 3 * ( ( y + 4900 + ( m - 14 ) / 12 ) / 100 ) ) / 4 + d - 32075
End Function
VBEND
VBEval>MyJulian,jDate
MJT Net Support
[email protected]

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Feb 16, 2005 7:48 pm

That's better :lol:

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts