Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

pscustomobject help Expand / Collapse
Author
Message
Posted Wednesday, October 23, 2013 1:02 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Today @ 5:20 AM
Points: 428, Visits: 947
Hi gang,

I have an array, $Data, having a bunch of elements, $Datum, each of which contains something like this:

@{Date =30-Nov-12; Billing
Week=1; Billing
Month=DECEMBER; Q=Q1; Weekday=Friday; Calendar
Month=November; Day=30; Year=2012; Time Due=8:00 AM)

So for each $Datum, how can access the value, that's on the other side of "Date = " for example?

P




Post #1507802
Posted Wednesday, October 23, 2013 1:36 PM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, August 22, 2014 6:08 AM
Points: 60, Visits: 890
If I understand correctly you have an array of hashes something like this.
$x = @{Date ='30-Nov-12'; 
BillingWeek='1';
BillingMonth='DECEMBER';
Q='Q1';
Weekday='Friday';
CalendarMonth='November';
Day='30';
Year='2012';
TimeDue='8:00 AM'
}

$y = @{Date ='29-Oct-13';
BillingWeek='2';
BillingMonth='November';
Q='Q2';
Weekday='Thursday';
CalendarMonth='October';
Day='29';
Year='2013';
TimeDue='9:00 AM'
}
$data = @($x, $y)

If so here’s one way to pick out individual values.
$data[0].Date  # 30-Nov-12
$data[1].Date # 29-Oct-13
$data[0].Weekday # Friday

Post #1507810
Posted Thursday, October 24, 2013 5:47 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Today @ 5:20 AM
Points: 428, Visits: 947
Yup, got it. Was not getting any values for Date because column name had a trailing space.

Thanks Bruce.



Post #1507983
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse