01-31-2013 01:54 PM
How do I take a date format like 1/12/2013 and create a new channel with just the month, and one with just the year ?
I want to be able to look at month over month trend on data.
Solved! Go to Solution.
02-01-2013 01:28 AM - edited 02-01-2013 01:32 AM
Hello Jcheese,
assuming your time channel is "Time", and all channels are in the first group:
Dim i
Dim oCh_source : Set oCh_source = Data.Root.ChannelGroups(1).Channels("Time")
Dim oCh_date : Set oCh_date = Data.Root.ChannelGroups(1).Channels.Add("Date",DataTypeFloat64)
Dim oCh_month : Set oCh_month = Data.Root.ChannelGroups(1).Channels.Add("Month",DataTypeFloat64)
Dim oCh_year : Set oCh_year = Data.Root.ChannelGroups(1).Channels.Add("Year",DataTypeFloat64)
For i = 1 To ChnLength(1)
oCh_date(i) = Val(Str(oCh_source(i), "#MM/DD/YYYY"))
oCh_month(i) = Val(Str(oCh_source(i), "#MM"))
oCh_year(i) = Val(Str(oCh_source(i), "#YYYY"))
Next
02-01-2013 04:37 AM
Hello Jcheese,
In addition to Dia791 suggestion you have to other possible ways in DIAdem 2012:
A) Using the VBS commands YEAR and MONTH
Dim i Dim oCh_source : Set oCh_source = Data.Root.ChannelGroups(1).Channels("Time") Dim oCh_month : Set oCh_month = Data.Root.ChannelGroups(1).Channels.Add("Month1",DataTypeFloat64) Dim oCh_year : Set oCh_year = Data.Root.ChannelGroups(1).Channels.Add("Year1",DataTypeFloat64) For i = 1 To oCh_source.Size oCh_month(i) = month(oCh_source(i)) oCh_year(i) = year(oCh_source(i)) Next
B) Using a DIAdem command:
Call Calculate ("Ch(""[1]/Month"")= RTP(Ch(""[1]/Time""), ""M"")") Call Calculate ("Ch(""[1]/Year"")= RTP(Ch(""[1]/Time""), ""Y"")")
Greetings
Walter
02-01-2013 08:19 AM
worked thanks