Search code examples
f#deedlefslab

F# Deedle GetSlice() error "expects to have type DateTime option"


I am getting an error when trying to use the GetSlice() method.

cl.Rows.GetSlice( DateTime(2014,12,28,20,0,0), DateTime(2014,12,28,23,0,0))

The error is: This expression was expected to have type DateTime option but here has type DateTime. This error is given for both parameters ( DateTime(2014,12,28,20,0,0), DateTime(2014,12,28,23,0,0) ) in the above code

Could some one explain the differnce between type of 'DateTime option' a type of 'DateTime'. What would be the correct correct syntax to use for the above code?

FsLab version(0.3.17)


Solution

  • The method GetSlice expects both parameter of type DateTime option (as the compiler helpfully tells you), but you're providing just DateTime.

    To create a value of type 't option, use constructor Some:

    cl.Rows.GetSlice( Some (DateTime(2014,12,28,20,0,0)), Some (DateTime(2014,12,28,23,0,0)) )