Hi,
if you are VB Friendly, here you are :)
It is a function you can call from MS Access Report or slightly change it to run in vbscript...
Option Compare Database
Public Function CreateDFS(StationName As String, ItemName As String, EumType As Double, ItemType As Double, TimeField As String, ValueField As String) As String
Dim TSValue As Double
Dim TSDate As Date
Dim TS As TSObject
Dim TimeVar As Date
Dim Item As TSItem
Dim RS As Recordset 'Managing timeseries
Dim SQL As String
SQL = "SELECT " & StationName & ".Profile FROM " & StationName & " GROUP BY " & StationName & ".Profile;"
Set RS = CurrentDb.OpenRecordset(SQL)
Dim Serie As Variant 'setting dfs0 series names to var Serie
With RS
.MoveLast
.MoveFirst
Serie = .GetRows(.RecordCount)
End With
Dim Count As String
Set RS = CurrentDb.OpenRecordset(StationName)
For Each Ser In Serie
Set TS = New TSObject
TS.Time.TimeType = Non_Equidistant_Calendar
Set Item = TS.NewItem
TS.Item(1).Name = ItemName 'name of station - set to TS_name ?
TS.Item(1).ValueType = Instantaneous
TS.Item(1).EumType = EumType 'select from table > DataType <
TS.Item(1).EumUnit = ItemType 'default - (jav) ask programmers...
TS.Connection.FileTitle = Ser
RS.Filter = "Profile = '" & Ser & "'"
Set RSfiltr = RS.OpenRecordset
RSfiltr.MoveLast
Count = RSfiltr.RecordCount 'Counting
RSfiltr.Sort = "[" & TimeField & "]"
RSfiltr.MoveFirst
For i = 1 To Count 'stepping on rows & copying values to DFS object
TS.Time.AddTimeSteps 1
TSDate = RSfiltr(TimeField)
TS.Time.SetTimeForTimeStepNr i, TSDate
TSValue = RSfiltr(ValueField)
TS.Item(1).SetDataForTimeStepNr i, TSValue
RSfiltr.MoveNext
Next
'Finishing & saving the file
TS.Item(1).DataType = Type_Float
TS.Connection.FilePath = "C:\_Model\Calibration\Data\" & Ser & ".dfs0"
TS.Connection.Save
Next Ser
RS.Close
Set RS = Nothing
End Function